하나의 폴더에 하나의 지오 데이터베이스와 두 개의 다른 파일 (txt)이 있습니다. 나는 지퍼를 사용하고 지퍼를 쌌다. 이제는이 폴더에 gdb, txt, txt 및 새로운 zip 파일이 있습니다. 이제는 압축 된 파일을 삭제해야하므로 폴더의 zip 파일 만 삭제됩니다. 다음 코드 작성 :python을 사용하여 폴더에서 파일 삭제
def remove_files():
for l in os.listdir(DestPath):
if l.find('zipped.zip') > -1:
pass
else:
print ('Deleting ' + l)
os.remove(l)
을하지만 가지고 :
이Error Info:
[Error 2] The system cannot find the file specified: 'geogeo.gdb'
이 사람이 나를 도울 수 있습니까? 미리 감사드립니다.
대신의'l.find ('zipped.zip를')> -1' 단순히 압축 ''사용할 수 있습니다 .zip 'in l' – ThiefMaster
확인. 고맙습니다!!! – Z77