波纹管是从两个 txt 文件中获取值以生成另一个 txt 文件的代码
plate1, mjd1, fiber1, d1, pval1 = np.loadtxt('combine3ga.txt', unpack='True')
plate2, mjd2, fiber2, d2, pval2 = np.loadtxt('combine4ga.txt', unpack='True')
with open('ekek2.txt', 'w') as outfile:
for i in range(len(plate1)):
if d2[i] < d1[i] and pval2[i] > 0.8:
print plate2[i], mjd2[i], fiber2[i], d2[i], pval2[i]
with open('ekek2.txt', 'a') as outfile:
outfile.write('{0} {1} {2}\n'.format(plate2[i], mjd2[i], fiber2[i]))
输出文件的前几行看起来像
1958.0 53385.0 614.0
2214.0 53794.0 308.0
436.0 51883.0 634.0
我正在尝试使它的值是整数,不包括小数,就像
1958 53385 614
2214 53794 308
436 51883 634