UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ordinal not in range(...

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ordinal not in range(256)

在处理标题或网址为中文的文件或网页的时候,报UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ordinal not in range(256)错误,解决办法很简单。如下:

#只需将中文encode一下即可
name = '中文'.encode('utf-8')

完美解决!

posted @ 2019-02-11 16:45 aaronthon 阅读( ...) 评论( ...) 编辑 收藏

你可能感兴趣的:(UnicodeEncodeError: 'latin-1' codec can't encode characters in position 41-50: ordinal not in range(...)