python 删除目录及其所有档案的方法
###windows
import os
folder = "C:\\Folder Name"
command = "rmdir /s /q %s"
command = command % folder
result = os.system(command)
if result == 0:
print "delete success"
else:
print "delete fail"
###linux
import os
folder = "/Folder Name"
command = "rm -rf %s"
command = command % folder
result = os.system(command)
if result == 0:
print "delete success"
else:
print "delete fail"
没有评论:
发表评论