我有一个 python 脚本来为我安装/卸载一些经常使用的程序,并且在卸载后它还会清理一些快捷方式/文件夹。我曾经使用此代码删除文件夹
os.system('rd /S /Q "{0}\\{1}"'.format(dirname, name))
效果很好。我正在尝试将我的用法转换为os.system
,subprocess.call
所以我将上面的行更改为
subprocess.call(['rd', '/S', '/Q', '{0}\\{1}'.format(dirname, name)])
但这给出了错误
The system cannot find the file specified (2)
我必须错误地使用 subprocess.call 但我无法解决。任何帮助将不胜感激,谢谢。