你有没有被python的unicode,str之间的转码烦死

啥都不说,直接上解决方法,因为我默认你知道被这事烦的原理了(python的str,unicode等看官方文档)

  1. 在$PATH_HOME\Lib下新建一个py文件,命名为“sitecustomize.py”.
  2. 在该文本里加上如下语句 : 
    import sys
    
    sys.setdefaultencoding('utf-8')

参考:http://stackoverflow.com/questions/2276200/changing-default-encoding-of-python

听说python3里终于有了真正的string和byte类型了,就像java里一样。

原文地址:https://www.cnblogs.com/jcli/p/3098405.html