Python默认为Ascii编码在代码或者注释中出现中文会报如下错误
SyntaxError: Non-ASCII character ‘\xe4’ in file test.py on line x, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
解决方法为在文件开头加入[code]# -*- coding: UTF-8 -*-[/code]或者[code]#coding=utf-8[/code]
如果大家在学习过程中,代码中包含中文,就需要在头部指定编码。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容