小弟在LInux和Python开发方面都是新手,最近照着网上的资料自己联系抓取网页内容。在ubuntu10.10环境下用eclipse+Pydev写了如下代码
代码: 全选
import os, sys
import urllib
def catchHtmlLines(url):
if url==None : return
try:
page = urllib.urlopen(url)
print 'success'
html = page.readlines()
page.close()
return html
except:
print "gGetHtmlLines() error!"
return
print catchHtmlLines('http://manglu.net/')
SyntaxError: Non-ASCII character '\xe5' in file /home/yudun/workspace/py/PythonPractise/src/catchLines.py on line 24, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
平常用eclipse+java全是utf-8没有问题,为什么一到python就不能输入输出中文了呢,起初我认为是eclipse的问题,之后发现vim编写之后用python aa.py运行也会这样。
请问一下,这种情况我应该如何解决?
我的OS版本为ubuntu 10.10.
注:
我按照网上的方法更改了locales,结果问题更大了,vim了一个java,编译都编译不了了。。。
代码: 全选
ell.java:3: 警告:编码 UTF8 的不可映射字符
System.out.println("���");