擅长:python、mysql、java
<p>首先,使用openwithencoding,<code>name_string.replace('"', '')</code>表示您正在使用utf-8。
试试这个</p>
<pre><code>def organize_data(location='G:\pythonFiles\problem 22.txt'):
with open(location, "r", encoding="utf-8") as f:
name_string = f.read()replace('\n', '')
name_string = name_string.replace('"', '')
names = name_string.split(',')
return names
print organize_data()
</code></pre>