在给定写入格式的情况下,将ASCII文件读取到2D数组中

时间:2019-05-21 08:18:26

标签: python-3.x

我已经具有写入文件的格式,我想在写入时读取它。

我尝试了几件事,例如使用numpy.loadtxt,numpy.genfromtxt等,但是我无法弄清楚如何正确处理它。

f = open(fnam, 'w')
for i in range(nth-1):
    for j in range(nz-1):
        f.write("%23.16e %23.16e %23.16e %23.16e %23.16e %23.16e\n" % (rdth[i], dz[j], acUz[i,j], acUzF[i,j], acPi[i,j], acOmgZ[i,j]) )
f.close()

我希望在编写上述数组时阅读它们。我是python的新手,所以我不知道该怎么做。

0 个答案:

没有答案