【问题标题】:python format and display non ASCII characters [duplicate]python格式并显示非ASCII字符[重复]
【发布时间】:2015-03-03 09:18:03
【问题描述】:

我正在尝试打印 £ 符号,但我似乎无法使用 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)

【问题讨论】:

  • 这是在 Python 中打印 Unicode 的其他问题的副本。阅读它们。

标签: python unicode utf-8


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多