Today, I installed the Pyscripter editor, and just to write the code, suddenly an exception occurred:
<span style= "Font-size:14px;color: #ff0000;" >>>> Traceback (most recent):
File "<string>", line 378, in Findmoduleorpackage
File "<string>", line 367, in Find_dotted_module
Unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 0-1: Ordinal No in range </span>
When Python is installed, the default encoding is ASCII. It is often the case that it cannot handle non-ASCII encoding. You will need to manually modify its coded character set at this time.
Query system default encoding:
In the shell, enter Python and enter the Python interpreter.
>>>import SYS
>>>sys.getdefaultencoding ()
Can.
If you want to set the default encoding:
>>>sys.setdefaultencoding (' UTF8 ')
You can set the default encoding to UTF8.
However, if you restart the Python interpreter, the default encoding becomes ASCII again.
If you want to permanently set the system default encoding to UTF8, then:
Create a new sitecustomize.py in the Python lib\site-packages folder, with the following content:
# Encoding=utf8
Import Sys
Reload (SYS)
Sys.setdefaultencoding (' UTF8 ')
Reference
http://blog.csdn.net/liuxingyu_21/article/details/27487391
Http://www.cnblogs.com/sislcb/archive/2008/11/26/1341453.html
Http://www.pythonfan.org/blog-3526-1416.html
Python encoding Problem: unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 0-1: Ordinal not in range (12