首页 > 代码库 > python中文报错

python中文报错

当输出中文时,错误信息如下:

SyntaxError at /time/

Non-ASCII character ‘\xe7‘ in file e:\pythonCode\firstsite\firstsite\view.py on line 15, but no encoding declared; see http://www.python.org/peps/pep-0263.html for 

 

经百度,必须在代码前面加注这两句

#coding=gbk

#coding=utf-8

才解决

 

from django.http import HttpResponse
#coding=gbk

#coding=utf-8
import datetime

python中文报错