UnicodeDecodeError: 'ascii' codec can't decode解决

今天拷贝了一段在WINDOW正常运行的python代码到mac上运行,提示
UnicodeDecodeError: 'ascii' codec can't decode

解决方法其实很简单,添加一下代码,强制修改格式即可。当然也可以用vim修改格式

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

相关文章:

  • 2021-06-17
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案