所以,这让我抓狂。如何将%apos
等编码字符转换为明文?使用Python 3.9。
我尝试了什么:
string = 'The guy blasts the other guy on 'Russia's Newsroom': 'Totally unfit' to be vice chancellor'
new_string = string.encode('utf-8', 'ignore')
print(new_string)
这与Unicode无关。它是HTML。
import html
print(html.unescape('''))
您正在寻找html.unescape((
https://docs.python.org/3/library/html.html#html.unescape
>>> html.unescape("'Russia's Newsroom'")
"'Russia's Newsroom'"