擅长:python、mysql、java
<p>由于<code>genfromtxt()</code>接受迭代器,因此可以通过应用转换函数传递迭代器,然后可以避免使用converters参数:</p>
<pre><code>import numpy as np
def conv(x):
return x.replace(',', '.').encode()
data = np.genfromtxt((conv(x) for x in open("test.txt")), delimiter=';')
</code></pre>