python3中报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'

  reload(sys)
    sys.setdefaultencoding("utf-8")
    f = open('.\\24.novel.txt','rb')
    str = f.read().decode('utf-8')
    f.close()

经过百度发现

Python3字符串默认编码unicode, 所以sys.setdefaultencoding也不存在了。。。。。。

所以删掉就好了。

相关文章:

  • 2021-06-17
  • 2021-09-26
  • 2022-12-23
  • 2021-04-07
  • 2021-11-21
  • 2021-12-09
  • 2021-11-19
  • 2022-12-23
猜你喜欢
  • 2021-07-18
  • 2022-12-23
  • 2022-01-07
  • 2021-09-02
  • 2021-12-16
  • 2021-11-25
  • 2022-12-23
相关资源
相似解决方案