python格式并显示非ASCII字符

时间:2015-01-05 19:13:40

标签: python unicode utf-8

我试图打印£符号,但我似乎无法使用format()方法执行此操作。我尝试以下操作:

curr_prefix = u"\xA3"
print "{}".format(curr_prefix)

但是我收到以下错误:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 0: ordinal not in range(128)

1 个答案:

答案 0 :(得分:2)

尝试print u"{}".format(curr_prefix)