#!/usr/bin/env python
import time
import os
import shutil

filelist=[]
rootdir="E:/mm618"
filelist=os.listdir(rootdir)
for f in filelist:
  filepath = os.path.join( rootdir, f )
  if os.path.isfile(filepath):
    os.remove(filepath)
    print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"->"+filepath+" removed!")
  elif os.path.isdir(filepath):
    shutil.rmtree(filepath,True)
    print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"->"+"dir "+filepath+" removed!")
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐