1
我正在嘗試使用numpy.genfromtxt()方法從txt文件中提取值。我的txt文件看起來是這樣的:不同列大小的NumPy genfromtxt
'! 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
靈活的對列的大小?