我有一个bash脚本,我用它来更新我家里的几台电脑.它利用deborphan程序识别我的系统不再需要的程序(显然是Linux).
bash脚本使用bash的参数扩展,这使我能够将deborphan的结果传递给我的包管理器(在本例中为aptitude):
aptitude purge $(deborphan --guess-all) -y
deborphan的结果是:
python-pip
python3-all
Run Code Online (Sandbox Code Playgroud)
我想将我的bash脚本转换为python(部分作为一个学习机会,因为我是python的新手),但我遇到了一个重大障碍.我对python脚本的明显开始是
subprocess.call(["aptitude", "purge", <how do I put the deborphan results here?>, "-y"])
Run Code Online (Sandbox Code Playgroud)
我已经为上面的subprocess.call中的一个参数尝试了一个单独的subprocess.call,仅用于deborphan而且失败了.
有趣的是,我似乎无法捕获deborphan结果:
deb = subprocess.call(["deborphan", "--guess-all"])
Run Code Online (Sandbox Code Playgroud)
将deborphan的结果作为参数的变量传递.
反正是否在Python中模拟Bash的参数扩展?