linux modify the default coding mode interpreter python

UnicodeEncodeError: 'ascii' codec can not encode characters in position 0-1: ordinal not in range
Workaround: Edit sitecutomize.py
Import SYS
reload (SYS)
sys.setdefaultencoding ( 'utf8')
This file two separate systems position
ubuntu system: /usr/lib/python2.7/sitecustomize.py
Fedora system: /usr/lib/python2.7/site-packages/sitecustomize.py
reasons: python when installed, the default is the ASCII code, when the program non-ascii coding occurs, python treatment often report such a mistake UnicodeDecodeError: 'ascii' codec can not decode byte 0x ?? in position 1: ordinal not in range (128), python can not handle non-ascii encoded in this case you need to set the default encoding of python, generally set utf8 encoding format.

Guess you like

Origin blog.51cto.com/14579200/2445429