我有一个带有
filename="data.OUT"
的文件,其中有很多行,例如
8 3.0 2.0 1.0 0.5 0.25 0.25 [(-5.254878050808644e-16+0j), (1.9349052915745023e-16+0j)] [(-3.026872012243266e-16+0j), (3.380866562575897e-16+0j)]
8 2.0 2.0 2.0 0.5 0.25 0.5 [(-2.4214426298686264e-18+0j), (0.0030397206475613592+0j)] [(4.725139008075004e-19+0j), (0.0030696070416985225+0j)]
为了从文件中读取数据,我尝试了
np.genfromtxt(filename, dtype=complex)
,这导致复值列的nan+0j
数据。我也试过np.loadtxt(filename,dtype=complex)
,结果是ValueError: complex() arg is a malformed string
。
在寻找解决方案的过程中,我遇到了this suggestion也没有帮助。
你对解决这个问题有什么建议吗?