Python AttributeError: module 'sys' has no attribute 'setdefaultencoding' Python 3 与 Python 2 有很大的区别,其中Python 3 系统默认使用的就是utf-8编码。 所以,对于使用的是Python 3 的情况,就不需要sys.setdefaultencoding(“utf-8”)这段代码。 最重要的是,Python 3 的 sys 库里面已经没有 setdefaultencoding() 函数了。