import os
import shutil
def del_Subdirectory(delDir):
delList = []
delList = os.listdir(delDir)
for f in delList:
filePath = os.path.join( delDir, f )
if os.path.isfile(filePath):
os.remove(filePath)
# print (filePath + " was removed!")
elif os.path.isdir(filePath):
shutil.rmtree(filePath,True)
# print("Directory: " + filePath +" was removed!")
需要注意的问题:
安装shutil,命令行应为:
pip install pytest-shutil



