phython编程入门,新手学习phython会遇到*.py文件运行时,出现如下错误:
SyntaxError: Non-UTF-8 code starting with '\xc7' in file E:\Pythondemo\2.py on l ine 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for de ta
SyntaxError: Non-UTF-8 code starting with 'xc1' in file C:...xxx.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
python版本:3.X
错误原因:是 xxx.py文件里有中文字符
SyntaxError: Non-UTF-8 code starting with ‘xc1′,’xc4′,’xc7’,解决方法
1.修改eclipse的编码,在Project–》properties–》resource –》test file encoding 选择other –》选择utf-8,应用保存即可
2.在页面第一行加上# -*- coding:utf-8 -*-或 # coding=gbk。
125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/3619.html