この文字列をPythonでどのようにデコードするのですか?PythonでHTML文字列をデコードする
title = 'Fast & Furious 6'
取得する:
Fast & Furious 6
ありがとうございました!
この文字列をPythonでどのようにデコードするのですか?PythonでHTML文字列をデコードする
title = 'Fast & Furious 6'
取得する:
Fast & Furious 6
ありがとうございました!
このコードでは、ascii rappresentationからcharシンボルが得られます。
title = 'Fast & Furious 6'
title = title[:-1]
substring=[x.strip() for x in title.split(';')]
titleFinal = ''
for ch in substring:
newstr = ch.replace("&#", "")
titleFinal+=chr(int(newstr))
print(titleFinal)
うまくいきました:)ありがとうございました! –
パーフェクト、歓迎です;)@CharlieSpecter – Daniele
ちょうど使用ビルトインhtml
モジュール:あなたの文字列として
import html
decoded_title = html.unescape(title))
がHTMLセーフシーケンス(数値文字参照)から構成されています。
これはXMLではなくHTMLでエンコードされています。 – Dijkgraaf