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
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.