import csv
d = []
with open('file.txt', 'r') as f:
data = list(csv.reader(f, delimiter=' ', skipinitialspace=True))
d += [data[0]]
d[0].append('e/p')
for l in list(data)[1::]:
l.append(round(float(l[1])/float(l[0]), 6))
d.append(l)
for i in d:
print '{:<9} {:<9} {:<9}'.format(*i)
使用^{} 的一个选项:
结果:
使用标准库,没有
pandas
的结果相同:结果:
python2或python3所需的格式。你知道吗
相关问题 更多 >
编程相关推荐