是否有一种优雅且更像 Python 的方法来检查软件包是否安装在 Debian 上?
在 bash 脚本中,我会这样做:
dpkg -s packagename | grep Status
关于在 Python 脚本中执行相同操作的建议?
最佳答案
这是一种pythonic方式:
import apt
cache = apt.Cache()
if cache['package-name'].is_installed:
print "YES it's installed"
else:
print "NO it's NOT installed"
关于python - 检查是否从 Python 安装了 Debian 软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3387961/