在python 2字符串中打印“ delta”希腊符号(Δ)

时间:2018-12-31 17:56:50

标签: python string character-encoding python-2.x

我需要在Python 2.7生成的报告中显示“Δreturn”。 但是,打印时出现以下错误。如何运作?

print u"Δ"
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0394' in position 8: ordinal not in range(128)

print u"Δ".encode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0394' in position 2: ordinal not in range(128)

print u"Δ".decode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0394' in position 2: ordinal not in range(128)

这些是How do I write a capital Greek "delta" as a string in Python 2.7?

中建议的方法

0 个答案:

没有答案