How to extract a text in a file with python. - A text begin with chaine.
My code is
fichier= open("Service.txt", "r")
for ligne in fichier:
if ligne==chaine:
#What do I do ?
fichier.close()
If I understood question correctly:
test.txt
fsdfj ljkjl
sdfsdf ljkkk
some ldfff
fffl lll
ppppp
script:
chaine = 'some'
with open("test.txt", "r") as f:
text = f.read()
i = text.find(chaine)
print(text[i:])
output:
some ldfff
fffl lll
ppppp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With