擅长:python、mysql、java
<p>使用<a href="http://pandas.pydata.org/" rel="nofollow">^{<cd1>}</a>库可能不是您的选择,但是如果是的话,它的函数<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.parsers.read_csv.html" rel="nofollow">^{<cd2>}</a>有一个<code>decimal</code>参数,可以用来配置小数点字符。例如</p>
<pre><code>In [36]: !cat file.ssv
0; 0,28321815; 0,5819178
1; 0,56868281; 0,85621369
2; 0,24022026; 0,53490058
3; 0,63641921; 0,0293904
4; 0,65585546; 0,55913776
In [37]: import pandas as pd
In [38]: df = pd.read_csv("file.ssv", delimiter=';', decimal=',', header=None)
In [39]: df
Out[39]:
0 1 2
0 0 0.283218 0.581918
1 1 0.568683 0.856214
2 2 0.240220 0.534901
3 3 0.636419 0.029390
4 4 0.655855 0.559138
[5 rows x 3 columns]
</code></pre>
<p>然后你就拥有了熊猫的所有优点来操纵这些数据。或者您可以将数据帧转换为numpy数组:</p>
^{pr2}$