python 刪除目錄及其所有檔案的方法

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"