我在使用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/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)
我尝试使用Unicode函数将字符串转换为Unicode,但是我没有找到解决方案。我尝试使用sys.setdefaultencoding('utf8')
,但也不起作用。