2

我想 <p在有 \r\n\r\n 的地方嵌入 > 标签。

u“终于斯里兰卡出现了,阻止了他们的第一个 5-0 系列粉饰,并在连续 9 场 ODI 胜利中阻止了印度。\r\n\r\nYuvraj Singh 打了 62 球,打出了梦幻般的击球,让印度保持在比赛中尽管三柱门落在他周围。\r\n\r\n也许抛掷起了很大的作用。这只是 Mahela Jayawardene 在过去 11 次中第二次用硬币击败 Mahendra Singh Dhoni。\r\n\r\n它是 Jayasuriya 为斯里兰卡提供了跳板。\r\n\r\n在 Jayasuriya 被解雇后,烟火可能已经停止,但奔跑仍在以公平的速度进行。”

我尝试使用 BeautifulSoup 解决这个问题,但找不到解决方法。任何人都可以对此有所了解。提前致谢。

4

1 回答 1

5
''.join('<p>%s</p>' % line for line in text.split('\r\n\r\n'))
# Results:
u"<p>Finally Sri Lanka showed up, prevented their first 5-0
series whitewash, and stopped India at nine ODI wins in a row. </p>
<p>For 62 balls Yuvraj Singh played a dream knock, keeping India in the 
game despite wickets falling around him. </p><p>Perhaps the toss played
a big part. This was only the second time Mahela Jayawardene beat Mahendra
Singh Dhoni with the coin in the last 11 occasions. </p>
<p>It was Jayasuriya who provided Sri Lanka with the springboard. </p>
<p>The pyrotechnics may have stopped upon Jayasuriya's dismissal, but 
the runs kept coming at a fair pace.</p>"
于 2009-02-09T10:15:15.477 回答