【发布时间】:2019-06-30 15:11:19
【问题描述】:
我收到了错误
UnicodeDecodeError:“ascii”编解码器无法解码位置 138 中的字节 0xc3:序数不在范围内 (128)
当我尝试做的时候
from django.utils.encoding import smart_str
u'{}'.format(smart_str('ø'))
但是documentation 说这个函数的默认编码是utf-8,我认为应该包括'ø'。我在 Python 2.7 上使用 Django 1.11。我在这里错过了什么?
【问题讨论】:
-
你的 python 和 django 版本是多少?我试过你的代码,但它没有引发错误。我的python版本是
3.7,django版本是2.1.5 -
将这些细节添加到我的问题中。
标签: python django python-2.7 utf-8 character-encoding