修改Python默认编码为utf8

    Read

修改默认代码到utf8:
[python]
[root@hz ~]# python
Python 2.7.7 (default, Jun 28 2014, 18:11:47)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> ^C
>>> reload(sys)

>>> sys.setdefaultencoding('utf8')
>>> reload(sys)

>>> sys.getdefaultencoding()
'utf8'
[/python] SourceByrd's Weblog-https://note.t4x.org/other/change-ascii-to-utf8/

申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Byrd
  • by Published on July 1, 2014
  • 原文链接:https://note.t4x.org/other/change-ascii-to-utf8/
匿名

Comment

Anonymous

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: