On Friday, August 4, 2017 at 12:27:02 PM UTC+3, ast wrote: > <alon.naj...@gmail.com> a écrit dans le message de > news:b6cc4ee5-71be-4550-be3e-59ebeee7a...@googlegroups.com... > > 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")
thanks man! that works -- https://mail.python.org/mailman/listinfo/python-list