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()

Found by Baidu

Python 3 string encodes Unicode by default, so sys. Set default encoding doesn't exist

So just delete it

Similar Posts: