def deleteDirectory(self,current_path): if not os.path.exists(current_path): self.logger.info(current_path + "does not exist, go on") return assert os.path.isdir(current_path), current_path + " is not directory" current_filelist = os.l…
python 中有很多内置库可以帮忙用来删除文件夹和文件,当面对要删除多个非空文件夹,并且目录层次大于3层以上时,仅使用一种内置方法是无法达到彻底删除文件夹和文件的效果的,比较low的方式是多次调用直到删除.但是,我们可以结合多个内置库函数,达到一次删除非空文件夹,不管其目录层次有多深. import os import shutil import traceback import globalvar def misc_init() # clean the test result folder…