python中文注释报错问题

Python中如果有中文注释则通常会报错:

sys:1: DeprecationWarning: Non-ASCII character '\xe6' in file ./backup.pyw on line 7, but no encoding declared; 

        see http://www.python.org/peps/pep-0263.html for details。

这是因为文件中有非ASCII字符,需要在第一行或第二行指定编码声明。修改方法是,必须在第一行或者第二行加上

#coding=<encoding name>,<encoding name>应该与vi中的set fileencoding值相对应

posted @ 2013-09-09 10:26  gxcherie  阅读(559)  评论(0编辑  收藏  举报