<p>我认为<code>pandas</code>支持这种开箱即用的方式,如果您可以选择的话。在</p>
<p>看看<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html</a></p>
<p><code>sep</code>参数:</p>
<blockquote>
<p>sep : str, default ‘,’</p>
<p>Delimiter to use. If sep is None, the C engine cannot automatically detect the separator, but the Python parsing engine can, meaning the latter will be used and automatically detect the separator by Python’s builtin sniffer tool, csv.Sniffer. In addition, separators longer than 1 character and different from '\s+' will be interpreted as regular expressions and will also force the use of the Python parsing engine. Note that regex delimiters are prone to ignoring quoted data. Regex example: '\r\t'</p>
</blockquote>
<p>您还可以使用<code>.values</code>方法iirc将pandas数据帧转换回numpy数组</p>
<p>(<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.values.html" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.values.html</a>)</p>