0
从一个网页,我srcaped一个词“Zápas”。问题在于我的数据中最接近的版本如下所示:在windows-1250编码之后的Z \ xe1pas。没有那个str(a)有一些ANSI错误。 谢谢你的帮助。编码斯洛伐克字母,如:ášČé
我尝试:
def encode(text):
return text.encode('windows-1250')...
...
for cell in row.findAll(['td', 'th']):
cell=encode(cell.get_text().strip())
a.append(cell)
foo.write(str(a)+"\n")
为什么你手动编码而不是让'foo'处理它? –
对于涉及unicode的任何事情,指定Python 2或Python 3以及(最好)标记非常重要。 – nigel222