2017-10-15 88 views

回答

1

使用此代码,您从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) 
+0

它运作良好:)谢谢! –

+0

完美,欢迎您;)@CharlieSpecter – Daniele

0

只需使用内置html模块:

import html 
decoded_title = html.unescape(title)) 

为您的字符串由HTML安全序列(数字字符引用)的。