<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](runpy.xhtml "runpy --- Locating and executing Python modules") | - [上一頁](pkgutil.xhtml "pkgutil --- Package extension utility") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [導入模塊](modules.xhtml) ? - $('.inline-search').show(0); | # [`modulefinder`](#module-modulefinder "modulefinder: Find modules used by a script.") --- 查找腳本使用的模塊 **源碼:** [Lib/modulefinder.py](https://github.com/python/cpython/tree/3.7/Lib/modulefinder.py) \[https://github.com/python/cpython/tree/3.7/Lib/modulefinder.py\] - - - - - - 該模塊提供了一個 [`ModuleFinder`](#modulefinder.ModuleFinder "modulefinder.ModuleFinder") 類,可用于確定腳本導入的模塊集。 `modulefinder.py` 也可以作為腳本運行,給出 Python 腳本的文件名作為參數,之后將打印導入模塊的報告。 `modulefinder.``AddPackagePath`(*pkg\_name*, *path*)記錄名為 *pkg\_name* 的包可以在指定的 *path* 中找到。 `modulefinder.``ReplacePackage`(*oldname*, *newname*)允許指定名為 *oldname* 的模塊實際上是名為 *newname* 的包。 *class* `modulefinder.``ModuleFinder`(*path=None*, *debug=0*, *excludes=\[\]*, *replace\_paths=\[\]*)該類提供 [`run_script()`](#modulefinder.ModuleFinder.run_script "modulefinder.ModuleFinder.run_script") 和 [`report()`](#modulefinder.ModuleFinder.report "modulefinder.ModuleFinder.report") 方法,用于確定腳本導入的模塊集。 *path* 可以是搜索模塊的目錄列表;如果沒有指定,則使用 `sys.path` 。 *debug* 設置調試級別;更高的值使類打印調試消息,關于它正在做什么。 *excludes* 是要從分析中排除的模塊名稱列表。 *replace\_paths* 是將在模塊路徑中替換的 `(oldpath, newpath)` 元組的列表。 `report`()將報告打印到標準輸出,列出腳本導入的模塊及其路徑,以及缺少或似乎缺失的模塊。 `run_script`(*pathname*)分析 *pathname* 文件的內容,該文件必須包含 Python 代碼。 `modules`一個將模塊名稱映射到模塊的字典。 請參閱 [ModuleFinder 的示例用法](#modulefinder-example)。 ## [`ModuleFinder`](#modulefinder.ModuleFinder "modulefinder.ModuleFinder") 的示例用法 稍后將分析的腳本(bacon.py): ``` import re, itertools try: import baconhameggs except ImportError: pass try: import guido.python.ham except ImportError: pass ``` 將輸出 bacon.py 報告的腳本: ``` from modulefinder import ModuleFinder finder = ModuleFinder() finder.run_script('bacon.py') print('Loaded modules:') for name, mod in finder.modules.items(): print('%s: ' % name, end='') print(','.join(list(mod.globalnames.keys())[:3])) print('-'*50) print('Modules not imported:') print('\n'.join(finder.badmodules.keys())) ``` 輸出樣例(可能因架構而異): ``` Loaded modules: _types: copyreg: _inverted_registry,_slotnames,__all__ sre_compile: isstring,_sre,_optimize_unicode _sre: sre_constants: REPEAT_ONE,makedict,AT_END_LINE sys: re: __module__,finditer,_expand itertools: __main__: re,itertools,baconhameggs sre_parse: _PATTERNENDERS,SRE_FLAG_UNICODE array: types: __module__,IntType,TypeType --------------------------------------------------- Modules not imported: guido.python.ham baconhameggs ``` ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](runpy.xhtml "runpy --- Locating and executing Python modules") | - [上一頁](pkgutil.xhtml "pkgutil --- Package extension utility") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [導入模塊](modules.xhtml) ? - $('.inline-search').show(0); | ? [版權所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 軟件基金會是一個非盈利組織。 [請捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [發現了問題](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 創建。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看