D:\pythonide\pythontest\venv\Scripts\python.exe D:/pythonide/pythontest/test1.py
File "D:/pythonide/pythontest/test1.py", line 8
SyntaxError: Non-ASCII character '\xe5' in file D:/pythonide/pythontest/test1.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Process finished with exit code 1
刚刚接触python
源代码:
i=100
while (i>0):
i=i-1
print i
for letter in 'Python':
print '当前字母:'+letter
上述错误是因为我在代码中使用的中文的字符
解决办法:在文件的最上方加上:#coding=UTF-8
:
#coding=UTF-8
i=100
while (i>0):
i=i-1
print i
for letter in 'Python':
print '当前字母:'+letter