Python UnicodeDecodeError读取CSV中的字符串
我在阅读python中的一些字符时遇到问题 我有一个UTF-8格式的csv文件,我正在读取,但当脚本读取时:Python UnicodeDecodeError读取CSV中的字符串,python,unicode,csv,Python,Unicode,Csv,我在阅读python中的一些字符时遇到问题 我有一个UTF-8格式的csv文件,我正在读取,但当脚本读取时: Preußen Münster-Kaiserslautern II 我得到这个错误: Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/
Preußen Münster-Kaiserslautern II
我得到这个错误:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 515, in __call__
handler.get(*groups)
File "/Users/fermin/project/gae/cuotastats/controllers/controllers.py", line 50, in get
f.name = unicode( row[1])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordinal not in range(128)
回溯(最近一次呼叫最后一次):
文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine default.bundle/Contents/Resources/google\u appengine/google/appengine/ext/webapp/\uuuuuuuuuu init\uuuuuuuuuuuuu.py”,第515行,在调用中__
handler.get(*组)
get中第50行的文件“/Users/fermin/project/gae/cuotastats/controllers/controllers.py”
f、 名称=unicode(第[1]行)
UnicodeDecodeError:“ascii”编解码器无法对位置4中的字节0xc3进行解码:序号不在范围内(128)
我尝试使用Unicode函数并将字符串转换为Unicode,但还没有找到解决方案。我尝试使用
sys.setdefaultencoding('utf8')
,但这也不起作用。尝试中描述的unicode\u csv\u reader()
生成器