擅长:python、mysql、java
<p>我不会为此使用正则表达式,因为您不需要它。看看这个:</p>
<pre><code>text = "Hey, this is paragraph 1 \n and this is paragraph 2 \n and this will be paragraph 3"
html = ''
for line in text.split('\n'):
html += '<p>' + line + '</p>'
print html
</code></pre>
<p>使其成为一行,因为越短越好,越清晰:</p>
^{pr2}$