Python: Set the default encoding of python

There are two ways to set the default encoding python:
Scheme a: place the following procedure: 

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

 


Scheme II: In the python Lib \ site-packages folder (print sys.path can view specific path) for a new sitecustomize.py, content:

Python code 
 # encoding = UTF8 
Import SYS

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

At this time, restart the python interpreter, execution sys.getdefaultencoding (), found that the coding has been set to the utf8, after several restart, the same effect, because the system when the python start, call the file itself, setting system default encoding, without the need to manually add each time resolution code, once belonging solution

Guess you like

Origin www.cnblogs.com/channy14/p/11684210.html