Adding Chinese comments to Python

Recently developed and learned Pyton, when adding Chinese comments, the running program reports an error: 

File "red.py", line 10
SyntaxError: Non-ASCII character '\xe5' in file red.py on line 10, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Solution: 
Add a sentence to the first or second line of the Python script file:

#coding:gbk or
#coding:utf - 8  or
##-*- coding : gbk -*-

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324472728&siteId=291194637