#!/usr/bin/env python
#coding=utf-8
import os
import shutil
filelist=[]
rootdir="E://11111"
filelist=os.listdir(rootdir)
print filelist
for f in filelist:
    filepath = os.path.join( rootdir, f )
    if os.path.isfile(filepath):
        os.remove(filepath)
        print filepath+" removed!"
    elif os.path.isdir(filepath):
        shutil.rmtree(filepath,True)
        print "dir "+filepath+" removed!"

Logo

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

更多推荐