我使用BeautifulSoup解析一些html,Spyder作为我的编辑器(这两种工具都很棒!)。该代码运行正常的Spyder的,但是当我试图执行从终端的.py文件,我得到一个错误:UnicodeEncodeError - 在Spyder中工作,但不是从终端执行时
file = open('index.html','r')
soup = BeautifulSoup(file)
html = soup.prettify()
file1 = open('index.html', 'wb')
file1.write(html)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 5632: ordinal not in range(128)
我在Linux服务器上运行的openSUSE,使用zypper的安装Spyder的。 有没有人有任何建议这个问题可能是什么? 非常感谢。