擅长:python、mysql、java
<p>您可以使用<a href="https://numpy.org/doc/stable/index.html" rel="nofollow noreferrer">numpy</a>的<a href="https://numpy.org/doc/1.20/reference/generated/numpy.genfromtxt.html" rel="nofollow noreferrer">^{<cd1>}</a>读取文件,然后对索引列和数组进行切片<a href="https://numpy.org/doc/stable/reference/generated/numpy.sum.html" rel="nofollow noreferrer">^{<cd2>}</a>:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
my_data = np.genfromtxt(csvfile, delimiter=',')
print(my_data[:,1:].sum(axis=0))
</code></pre>
<p>给出:</p>
<pre class="lang-none prettyprint-override"><code>[0. 0. 5. 1.]
</code></pre>