擅长:python、mysql、java
<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy.loadtxt" rel="nofollow noreferrer">If you want a numpy array and each row in the text file has the same number of values</a>:</p>
<pre><code>a = numpy.loadtxt('data.txt')
</code></pre>
<p>没有纽比:</p>
<pre><code>with open('data.txt') as f:
arrays = list(csv.reader(f, delimiter=' ', quoting=csv.QUOTE_NONNUMERIC))
</code></pre>
<p><a href="https://stackoverflow.com/a/11052880/4279">Or just</a>:</p>
<pre><code>with open('data.txt') as f:
arrays = [map(float, line.split()) for line in f]
</code></pre>