我读过Print the "approval" sign/check mark (✓) U+2713 in Python,但没有一个答案对我有用。我正在Windows上运行Python2.7。
print u'\u2713'
产生此错误:
exceptions.UnicodeEncodeError:“charmap”编解码器无法对0-1位置的字符进行编码:字符映射到
这是:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print '✓'
不工作,因为我在使用Windows。
print u'\u2713'.encode('utf8')
“打印出-œ”,这不是正确的字符。
print('\N{check mark}')
只是很傻。这是印刷\N{check mark}
的字面意思。
发布于 2014-08-16 18:31:42
阅读http://www.joelonsoftware.com/articles/Unicode.html,您将了解正在发生的事情。
坏消息是:您将无法打印该字符,因为它在Windows终端的默认文本编码中根本不可用。修改您的终端配置,使用"utf-8“而不是默认的"cp-852”或任何默认的窗口的cmd,您应该是好的,但只有在阅读了上面的文章,认真。
https://stackoverflow.com/questions/25342638
复制相似问题