import lxml.etree as ET
print ("Desired:")
print (ET.tostring(string_res, encoding='utf-8', method='xml'))
string_res.text = ''
string_res.text = value['Value']
print ("Desired:")
print string_res.text
print ("Not desired:")
print (ET.tostring(string_res, encoding='utf-8', method='xml'))
结果是
Desired:
<![CDATA[<b>hello</b>]]>
Desired:
<![CDATA[<b>hello</b>]]>
Not desired:
<![CDATA[<b>hello</b>]]>