Skip to main content
 首页 » 编程设计

python之Python 中的 HTML 字符串解码

2025年01月19日32wayfarer

如何在python中解码这个字符串?

title = 'Fast & Furious 6' 

获得:

Fast & Furious 6 

谢谢!

请您参考如下方法:

通过这段代码,您可以从 ascii 表示法中获得字符符号。

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)