[英]Script runs fine in PyScripter, crashes in python.exe (encoding error with Beautifulsoup)
def getPlural():
plural = soup.find("span", class_="form-of lang-de plural-form-of")
if plural == None:
return None
else:
return plural.get_text()
问题似乎出在我的代码的这一部分。 Pyscripter设法处理得很好,Python.exe返回Error: 'charmap' codec can't encode character \\xe4 in position 9: character maps to undefined.
PyScripter和Python.exe运行相同的版本(3.3)。 为什么是这样? 我该如何解决?
您可能会得到像这样的好成绩:
print plural.encode('utf-8')
要么
print plural.prettify().encode('utf-8')
+ + + + + + + + + + + + + + + _编辑:尝试......
print plural.get_text().decode('string-escape')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.