我正在閱讀與python 3.5 json文件。在這個文件中它有像「í」的字符。我想以這種格式打印它。如何讓下面的代碼正確地打印字符?Python閱讀字符串'í'並打印它
t = 'í'
print(t)
Traceback (most recent call last):
File "test.py", line 15, in <module>
print(t)
UnicodeEncodeError: 'ascii' codec can't encode character '\xed' in position 0: ordinal not in range(128)
[UnicodeEncodeError的可能重複: 'ASCII' 編解碼器不能編碼字符U位置20 '\ XA0':主要是有序不範圍(128)](http://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20) –
我不能再現這 - 它打印對於我來說足夠了。你確定你在使用Python 3嗎?在這種情況下,只有Python 2應該有這個錯誤。 –
這就是你使用Python 2運行時得到的錯誤 – abccd