我有一个python字符串:
<p> <a href="http://blog.alexmaccaw.com/how-to-travel-around-the-world-for-a-year">How to travel around the world for a year • Alex MacCaw<span class="small">blog.alexmaccaw.com</span> </a></p>
的
<type 'str'>
这个问题是由•
在我试图使用Jinja呈现它时引起的。在
最后出现这样的错误:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 125: ordinal not in range(128)
我试过各种编码和解码方法,但总有类似的错误。在
有什么想法吗?在
尝试使用htmll代码:
希望这有帮助!在
对python2中的文本使用
unicode
,而不是str
对象。尤其是对于非ASCII字符的文本。str
有时只是巧合。在(如果源文件中有非ASCII文本,则还需要指定源编码):
(在Python代码中而不是在模板或数据库中使用HTML可能也是个坏主意…)
相关问题 更多 >
编程相关推荐