小编fer*_*min的帖子

UnicodeDecodeError以CSV格式读取字符串

我在阅读python中的一些字符时遇到问题.

我有一个UTF-8格式的csv文件,我正在阅读,但是当脚本读取时:

Preußen Münster-Kaiserslautern II
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

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')但这也不起作用.

python csv unicode

3
推荐指数
1
解决办法
885
查看次数

标签 统计

csv ×1

python ×1

unicode ×1