【发布时间】:2011-08-07 01:23:22
【问题描述】:
我正在从文件中读取 Python 中的名字和姓氏,并且在编码时遇到问题。我想打印出名称,但收到“UnicodeEncodeError: 'charmap' codec can't encode character '\u021b' in position 11: character maps to undefined”这个代码:
first = obj.first_name.encode('utf-8')
last = obj.last_name.encode('utf-8')
first = first.decode('utf-8')
last = last.decode('utf-8')
print(first)
有什么问题?
【问题讨论】: