如何解码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安全序列(数字字符引用)的。
这是HTML编码不是XML。 – Dijkgraaf