擅长:python、mysql、java
<p>如果要将<code><br /></code>转换为换行符,请执行以下操作:</p>
<pre><code>def text_with_newlines(elem):
text = ''
for e in elem.recursiveChildGenerator():
if isinstance(e, basestring):
text += e.strip()
elif e.name == 'br':
text += '\n'
return text
</code></pre>