2016-09-27 65 views
-3

我想下面的HTML字符串與HTML標籤解碼HTML字符串使用python 2.7

\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e 

解碼我怎樣才能做到這在Python 2.7?

我有大的HTML字符串解碼。上面的例子只是其中的一部分。

PS:我已經在網絡解碼HTML字符串,但沒有提供很多解決方案,試圖幫助我編輯: 我已經提到這個https://stackoverflow.com/a/2087433/4350834 ,並得到了結果作爲

\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e 
+6

*「我已經嘗試過很多解決方案可用於解碼HTML字符串,但沒有任何東西可以幫助我」* - 那麼[mcve]在哪裏? – jonrsharpe

+1

**當你*「提到」*時發生了什麼**? – jonrsharpe

回答

3

你可以試試:

>>>text = "\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e".decode('unicode-escape') 
>>>print text 
u'<p><strong><span>About the Company </span></strong></p>' 
+0

這適用於我 – Prabhakar