def check_and_remove(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path, ignore_errors=true)
print("Deleted")
else:
print(path, " directory not found")
dirs_to_delete = [
'C:\Directory1',
'C:\Directory2',
'C:\Directory3'
]
check_and_remove()
将建议的shutil.rmtree(dir,ignore_errors = true)更改为shutil.rmtree(path,ignore_errors = true)
现在出现此错误-
回溯(最近通话最近): 在第53行的“ C:\ Users \ Temp \ PycharmProjects \ crm \ CRMReinstall.py”文件中 check_and_remove() TypeError:check_and_remove()缺少1个必需的位置参数:“ pathslist”
答案 0 :(得分:0)
在shutil.rmtree(dir, ignore_errors=true)
中,您正在使用dir
,这是python内置函数,也许您想执行shutil.rmtree(path, ignore_errors=true)
答案 1 :(得分:0)