python在windows 乱码如何解决?
初学中,运行一段代码报错如下:C:\Python27\python.exe E:/python脚本/test.py
File "E:/python�ű�/test.py", line 39
SyntaxError: Non-ASCII character '\xe5' in file E:/python�ű�/test.py on line 39, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Process finished with exit code 1
网上查了下,说是乱码
我的代码如下:
#C:\Python27\python.exe
# coding=gbk
for letter in 'python':
print "当前字母:",letter
fruits = ['banner','apple','pear']
for fruit in fruits:
print "当前字母:",fruits
print "see you again!"
Python 版本是2.7,IDE是PyCharm
请问如何解决? 应该是编码的问题,改成下面这个试试
#!/bin/env python
# -*- coding:utf-8 -*- 第一行加个
# coding=utf-8
经过验证
# -*- coding:utf-8 -*-
的写法在有的系统下不能正常工作 leeypp 发表于 2016-08-24 17:35
应该是编码的问题,改成下面这个试试
#!/bin/env python
# -*- coding:utf-8 -*-
我是Windows系统 bskay 发表于 2016-08-25 08:56
第一行加个
# coding=utf-8
你好,你的方法,我试过了,不行呢
页:
[1]