[問題] SOAP字串轉換

看板Python作者 (new life)時間16年前 (2009/07/30 17:32), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/2 (看更多)
請問一下,我從網路抓到一個SOAP封包的內容,長的像這樣: a=" &lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp= "urn:schemas-upnp-org:metadata-1-0/upnp/"xmlns:dlna="urn:schemas-dlna- org:metadata-1-0/" xmlns:pv="http://www.pv.com/pvns/" xmlns="urn:schem as-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;/DIDL-Lite&gt;" 請問一下我要怎麼把&lt;轉成< ? 我試過re.sub("&lt;", "<", a) 可是不work 不知是哪裡搞錯了? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 116.59.137.173

07/30 19:17, , 1F
不 work 是怎樣不 work? 我這邊試的結果是正常的
07/30 19:17, 1F

07/30 19:17, , 2F
另外如果只是單純地要置換字串可以用...
07/30 19:17, 2F

07/30 19:18, , 3F
a.replace('&lt;', '<')
07/30 19:18, 3F
文章代碼(AID): #1ASMYyIg (Python)
討論串 (同標題文章)
以下文章回應了本文
完整討論串 (本文為第 1 之 2 篇):
文章代碼(AID): #1ASMYyIg (Python)