import gc import shutil dirName = "myfolder" if os.path.exists(dirName): shutil.rmtree(dirName) os.mkdir(dirName)