【发布时间】:2015-12-09 13:44:30
【问题描述】:
我正在尝试使用 numpy.genfromtxt() 方法从 txt 文件中提取值。我的 txt 文件如下所示:
'! dt tot nsave readext\n',
' 0.002 200 500 F\n',
'!----------------------------------------------------------------------\n',
'! xdomain ydomain \n',
' 7.5 7.5\n',
'!----------------------------------------------------------------------\n',
'! maxnewts maxiters atol\n',
' 40 100 0.001\n',
'!----------------------------------------------------------------------\n',
'! p \n',
' 600 \n',
但是使用numpy.genfromtxt("file.txt", comments='!') 给了我:
Line #4 (got 2 columns instead of 4)
Line #7 (got 3 columns instead of 4)
Line #10 (got 1 columns instead of 4)
如何让numpy.genfromtxt 灵活调整列大小?
【问题讨论】:
标签: python numpy genfromtxt