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
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.