当前位置:首页 > django使用中文报错:Non-ASCII character \"xe6\" in file xxx, but no encoding declared;

django使用中文报错:Non-ASCII character \"xe6\" in file xxx, but no encoding declared;

点击次数:7355  更新日期:2011-10-22

在使用python+django的时候出现了这个错误,主要是因为用了中文

\r\r\n

解决方法是在文件的第一行加上

\r\r\n

 # -*- coding: utf-8 -*-

\r\r\n

这样就可以了

\r\r\n

 

\r\r\n

 

\r\r\n

SyntaxError at /admin/category

\r\r\n
Non-ASCII character '\xe6' in file D:\Documents\python\xxx.py on line 14, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details (views.py, line 14)