简单小练习_文本搜索自动解压并删除文件

# san -- unzip --delte
import os
import shutil

def scan_file():
    files  = os.listdir()
    for f in files:
        if f.endswith('.zip')
            return f

def unzip_it(f):
    folder_name = f.split('.')[0]
    target_path = './' + folder_name
    os.makedirs(target_path)
    shutil.unpack_archive(f,target_path)

def delte(f):
    os.remove(f)

while True:
    zip_file = scan_file()
    if zip_file:
        unzip_it(zip_file)
        delte(zip_file)

 

posted @ 2018-06-14 12:54  Erick-LONG  阅读(166)  评论(0编辑  收藏  举报