UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 537: ordinal not in range(128), referer: ...
当我尝试用“_”字符输出整个网站时,总是会出现这个错误。我正在使用Mako模板。怎么办?
最佳答案
出现错误的原因是某些代码将您的unicode模板字符串强制为python 2;您需要将呈现的模板编码为utf-8字节,并自己进行编码:
if isinstance(rendered, unicode):
rendered = rendered.encode('UTF-8')
# rendered is now guaranteed to be of type str
关于python - UnicodeDecodeError:'ascii'编解码器无法解码字节0xc5,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18877589/