<bdo id='2s88D'></bdo><ul id='2s88D'></ul>
  • <tfoot id='2s88D'></tfoot>

      1. <i id='2s88D'><tr id='2s88D'><dt id='2s88D'><q id='2s88D'><span id='2s88D'><b id='2s88D'><form id='2s88D'><ins id='2s88D'></ins><ul id='2s88D'></ul><sub id='2s88D'></sub></form><legend id='2s88D'></legend><bdo id='2s88D'><pre id='2s88D'><center id='2s88D'></center></pre></bdo></b><th id='2s88D'></th></span></q></dt></tr></i><div id='2s88D'><tfoot id='2s88D'></tfoot><dl id='2s88D'><fieldset id='2s88D'></fieldset></dl></div>
      2. <legend id='2s88D'><style id='2s88D'><dir id='2s88D'><q id='2s88D'></q></dir></style></legend>
      3. <small id='2s88D'></small><noframes id='2s88D'>

        检查是否从 Python 安装了 Debian 软件包

        Check if a Debian package is installed from Python(检查是否从 Python 安装了 Debian 软件包)

          <tfoot id='wo6ck'></tfoot>
        1. <legend id='wo6ck'><style id='wo6ck'><dir id='wo6ck'><q id='wo6ck'></q></dir></style></legend>
            <tbody id='wo6ck'></tbody>

              <small id='wo6ck'></small><noframes id='wo6ck'>

                • <bdo id='wo6ck'></bdo><ul id='wo6ck'></ul>
                  <i id='wo6ck'><tr id='wo6ck'><dt id='wo6ck'><q id='wo6ck'><span id='wo6ck'><b id='wo6ck'><form id='wo6ck'><ins id='wo6ck'></ins><ul id='wo6ck'></ul><sub id='wo6ck'></sub></form><legend id='wo6ck'></legend><bdo id='wo6ck'><pre id='wo6ck'><center id='wo6ck'></center></pre></bdo></b><th id='wo6ck'></th></span></q></dt></tr></i><div id='wo6ck'><tfoot id='wo6ck'></tfoot><dl id='wo6ck'><fieldset id='wo6ck'></fieldset></dl></div>

                  本文介绍了检查是否从 Python 安装了 Debian 软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否有一种优雅且更像 Python 的方法来检查软件包是否安装在 Debian 上?

                  Is there an elegant and more Python-like way to check if a package is installed on Debian?

                  在 bash 脚本中,我会这样做:

                  In a bash script, I'd do:

                  dpkg -s packagename | grep Status
                  

                  建议在 Python 脚本中做同样的事情?

                  Suggestions to do the same in a Python script?

                  推荐答案

                  这是pythonic的方式:

                  This is a pythonic way:

                  import apt
                  cache = apt.Cache()
                  if cache['package-name'].is_installed:
                      print "YES it's installed"
                  else:
                      print "NO it's NOT installed"
                  

                  这篇关于检查是否从 Python 安装了 Debian 软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                    <tfoot id='eay8J'></tfoot>

                      • <i id='eay8J'><tr id='eay8J'><dt id='eay8J'><q id='eay8J'><span id='eay8J'><b id='eay8J'><form id='eay8J'><ins id='eay8J'></ins><ul id='eay8J'></ul><sub id='eay8J'></sub></form><legend id='eay8J'></legend><bdo id='eay8J'><pre id='eay8J'><center id='eay8J'></center></pre></bdo></b><th id='eay8J'></th></span></q></dt></tr></i><div id='eay8J'><tfoot id='eay8J'></tfoot><dl id='eay8J'><fieldset id='eay8J'></fieldset></dl></div>
                        <legend id='eay8J'><style id='eay8J'><dir id='eay8J'><q id='eay8J'></q></dir></style></legend>

                          • <bdo id='eay8J'></bdo><ul id='eay8J'></ul>

                            <small id='eay8J'></small><noframes id='eay8J'>

                              <tbody id='eay8J'></tbody>