擅长:python、mysql、java
<p>这是因为第4行(即0,0,0)有三列,而不是前三行。你知道吗</p>
<p>相反,您可以将所有行串联起来并将其转换为一个数组:</p>
<pre><code>with open(path2) as f:
str_arr = ','.join([l.strip() for l in f])
int_arr = np.asarray(str_arr.split(','), dtype=int)
print(int_arr)
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
</code></pre>