<[email protected]> a écrit dans le message de
news:[email protected]...
Hi, I'm new to thing forum and to this programming in python!
can someone help me and write me how to write a program that do:
- search for a string in certain text file and if it founds the string it delete the file? and
print something?
thanks.
import os
pattern = "azerty"
found = False
with open("foo.txt", "r") as f:
for line in f:
if pattern in line:
found = True
break
if found:
os.remove("foo.txt")
--
https://mail.python.org/mailman/listinfo/python-list