0
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)。为什么是这样?我该如何解决这个问题?

4

1 回答 1

0

您可能会通过以下方式获得良好的运行:

print plural.encode('utf-8')

或者

print plural.prettify().encode('utf-8')

+ + + + + + ++ +++ + + + +_ 已编辑:试试这个...

print plural.get_text().decode('string-escape')
于 2014-04-16T15:19:00.283 回答