import os, glob strings = ("abcdefghijklmnopqrstuvwxyz") for file in glob.glob(r"C:\temp\python\*.txt"): lines = open(file).readlines() with open(file) as myFile: for num, line in enumerate(myFile, 1): if any(s in line for s in strings): val = num try: open(r'C:\temp\python\newfile.txt', 'w').writelines(lines[val:]) os.remove(file) os.rename(r'C:\temp\python\newfile.txt', file) except IndexError: pass
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.