UnicodeEncodeError:&x27;ascii';编解码器可以';t编码字符u'\u25cf';位置24:序号不在Python 2.7中的范围(128)内
我试图打印UnicodeEncodeError:&x27;ascii';编解码器可以';t编码字符u'\u25cf';位置24:序号不在Python 2.7中的范围(128)内,python,Python,我试图打印ascii字符和string,但出现以下错误: UnicodeEncodeError:“ascii”编解码器无法对位置24处的字符u'\u25cf'进行编码:序号不在范围内(128) 这是我的常量。图标\u黑色\u圆圈 ICON_BLACK_CIRCLE = u'\u25CF' 在这里,我试图用其他字符串打印它 print "{: ^71s}".format(constants.ICON_BLACK_CIRCLE + " - " + errormsg), s = "|
ascii
字符和string
,但出现以下错误:
UnicodeEncodeError:“ascii”编解码器无法对位置24处的字符u'\u25cf'进行编码:序号不在范围内(128)
这是我的常量。图标\u黑色\u圆圈
ICON_BLACK_CIRCLE = u'\u25CF'
在这里,我试图用其他字符串打印它
print "{: ^71s}".format(constants.ICON_BLACK_CIRCLE + " - " + errormsg),
s = "| |"
print(s)
如何修复此错误?这就是如何消除此异常的方法 只需将第二个字符串也设为unicode字符串
print u"{: ^71s}".format(constants.ICON_BLACK_CIRCLE + " - " +errormsg)