时间:2021-07-01 10:21:17 帮助过:123人阅读
代码如下:
import sys
print sys.getdefaultencoding()
代码如下:
[root@lee ~]# python a.py
ascii
代码如下:
import sys
sys.setdefaultencoding('utf-8')
print sys.getdefaultencoding()
代码如下:
[root@lee ~]# python a.py
Traceback (most recent call last):
File "a.py", line 4, in
sys.setdefaultencoding('utf-8')
AttributeError: 'module' object has no attribute 'setdefaultencoding'
提示:AttributeError: 'module' object has no attribute 'setdefaultencoding'?
代码如下:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print sys.getdefaultencoding()
代码如下:
[root@lee ~]# python a.py
utf-8