ubuntu python3 Unicodeincodeer错误
我现在在ubuntu和python 3.4下遇到了以下错误 只有一个带有两个中文unicode字符的打印ubuntu python3 Unicodeincodeer错误,ubuntu,python-3.x,encoding,Ubuntu,Python 3.x,Encoding,我现在在ubuntu和python 3.4下遇到了以下错误 只有一个带有两个中文unicode字符的打印 root@vps3:~# python3 a.py Traceback (most recent call last): File "a.py", line 1, in <module> print('\u4f60\u597d') UnicodeEncodeError: 'ascii' codec can't encode characters in position
root@vps3:~# python3 a.py
Traceback (most recent call last):
File "a.py", line 1, in <module>
print('\u4f60\u597d')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
看起来还可以
怎么了?请帮忙。最后我发现这是因为错误的文件编码 Windows下新更新的Pycharm IDE更改了默认编码 所以我的新代码文件编码变成了GBK,应该是utf8
我更改了IDE设置,更改了文件编码,一切都很好。对我来说很有用。标准输出的编码是什么?你所在的地区是什么?
>>> import sys
>>> print(sys.getdefaultencoding())
utf-8