删除本地文件夹: import os , string , datetime ; str = '/home/niuguoqin/tmp/tomcat/'; b = (datetime.datetime.now()).second + 5; while 1 : a = datetime.datetime.now(); if a.second == b : files = os.listdir(str); for file in files : os.remove(str+file); b = (a…
Python模糊查询本地文件夹去除文件后缀 import os,re def fuzzy_search(path): word= input('请输入要查询的内容:') for filename in os.listdir(path): #遍历指定文件夹 re_filename = re.findall('.\w+', str(filename)) #去除文件后缀名 if word in re_filename[0]: print(re_filename[0])…