簡體   English   中英

腳本在PyScripter中運行良好,在python.exe中崩潰(Beautifulsoup編碼錯誤)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM