擅长:python、mysql、java
<p>不过,我同意马特关于美妆的看法</p>
<p><strong>我在你的代码片段中添加了一些正则表达式,结果很好</strong></p>
<pre><code>import xml.etree.ElementTree as ET
import re
tree = ET.parse('data.xml')
root = tree.getroot()
data = {};
result = [];
for item in root.iter('benefit'):
cleaned = re.sub(r'<[^>]*>', '', ET.tostring(item, encoding="utf-8"));
result.append(cleaned)
print result;
//result ['Benefit: Using senses such as acute hearing and sensitivity to vibrations, you detect the location of opponents who are no more than 5 feet away from you. Invisibility and darkness are irrelevant, though it you discern incorporeal beings.\n\n\n ']
</code></pre>