我想从文件中读取一些数字,而我无法在两个列表中读取这些数字以进行进一步的计算,例如Mean和STDEV。
0.0000000 0.0000005
0.0100000 0.1675796
0.0200000 0.2042502
0.0300000 0.2064999
0.0400000 0.2237432
0.0500000 0.2245723
0.0600000 0.2365732
0.0700000 0.2433299
0.0800000 0.2556339
0.0900000 0.2569953
0.1000000 0.2658122
0.1100000 0.2718526
0.1200000 0.2741648
import os
directory= "/media/quinn/Joker/post_analysis/KBH00"
for x in range (252, 256):
os.chdir(directory + str(x) +'/')
print(os.getcwd())
with open ('rmsd.xvg', 'r') as rmsd:
line_19_to_end = rmsd.readlines()[18:]
print("Values of RMSD are:")
for line in line_19_to_end:
print("%s" %(line))
答案 0 :(得分:0)
在迭代时,在将每个值赋予浮动值之后,将第0位的所有值添加到新列表col1
,将第1位的所有值添加到另一个列表col2
。
import os
directory= "/media/quinn/Joker/post_analysis/KBH00"
for x in range (252, 256):
os.chdir(directory + str(x) +'/')
print(os.getcwd())
col1,col2=[],[]
with open ('rmsd.xvg', 'r') as rmsd:
line_19_to_end = rmsd.readlines()[18:]
print("Values of RMSD are:")
for line in line_19_to_end:
print("%s" %(line))
line = list(map(float, line.split()))
col1.append(line[0])
col2.append(line[1])
print(col1,'\n',col2)