Stack Overflow на русском Asked on July 24, 2020
import os, re
r = re.compile(r"[.]")
while True:
g = - 1
n = 0
way = input('Enter way to file')
c = 0
try:
f = open(way)
except FileNotFoundError:
print('Incorrect way to file')
else:
with open(way) as f:
while n != 4:
if f.readline().find("[TWAS]") != -1: n += 1
if n > 4:
f.close()
print('file was deleted')
FilePath = os.path.dirname(way)
FileName = os.path.basename(way)
SplitString = r.split(FileName)
FirstList = SplitString[:-1]
os.remove(way)
AllFiles = is.listdir(FilePath)
for SplitString in AllFiles:
g += 1
f = r.split(AllFiles[g])
SecondList = f[:-1]
if FirstList == SecondList:
NewArr = AllFiles
os.remove(NewArr[g])#Как раз эта функция не хочет работать. Если быть точнее, она говорит, что файла не существует, хотя он есть и должен удаляться.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP