Ma question est d'extraire un certain paragraphe (par exemple, généralement un paragraphe du milieu) d'un fichier à travers la regex en Python.Comment extraire un certain paragraphe d'un fichier, utilisez regex en python?
Un exemple de fichier est comme suit:
poem = """The time will come
when, with elation,
you will greet yourself arriving
at your own door, in your own mirror,
and each will smile at the other's welcome,
and say, sit here. Eat.
You will love again the stranger who was your self.
Give wine. Give bread. Give back your heart
to itself, to the stranger who has loved you
all your life, whom you ignored
for another, who knows you by heart.
Take down the love letters from the bookshelf,
the photographs, the desperate notes,
peel your own image from the mirror.
Sit. Feast on your life."""
Comment extraire le deuxième alinéa (ce qui signifie « tout ce que vous la vie ... l'étagère ») de cette utilisation poème regex en python?
Qu'avez-vous essayé jusqu'à présent? –
Capturez tout ce qui se trouve entre '\ n \ n'. –
Je me bats avec le modèle du deuxième paragraphe en ce moment. BESOIN D'AIDE POUR! – hoperose