Pregunta

quería incrustar etiquetas <p> donde cada vez hay un \ r \ n \ r \ n.

u "Finalmente Sri Lanka se presentó, impidió su primera lechada 5-0 la serie, y se detuvo a las nueve de la India ODI victorias seguidas. \ R \ n \ r \ nPor 62 bolas Yuvraj Singh jugó un sueño llamad, manteniendo la India en el juego a pesar de ventanillas cayendo a su alrededor. \ r \ n \ r \ nPerhaps el sorteo jugó un papel importante. Esta era la segunda vez Mahela Jayawardene venció Mahendra Singh Dhoni con la moneda en los últimos 11 ocasiones. \ r \ n \ r \ nSe era Jayasuriya que proporcionó Sri Lanka con el trampolín. \ r \ n \ r \ nLos pirotecnia pueden haber dejado en caso de despido de Jayasuriya, pero las carreras seguían llegando a un ritmo justo ".

He intentado solucionar esto usando BeautifulSoup pero no pudo encontrar la manera de salir de ella. ¿Puede alguien través de algo de luz sobre esto. Gracias de antemano.

¿Fue útil?

Solución

''.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>"
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top