2016-11-15 42 views
4

如何打印Python已有的庫。如osmathsocket打印Python本機庫列表

是否有類似"pip list" || "pip freeze"一個過程,我打印安裝庫? (我是Python的新手,如果我對python庫有一個可怕的誤解,請幫我解決)。

+0

可能重複[如何獲得本地安裝的Python模塊列表?](http://stackoverflow.com/questions/739993/how-can-i-get-a-list-of-本地安裝的python模塊) – GAVD

+0

@GAVD起初我以爲同樣的事情。但我認爲OP實際上是在尋找標準庫中的所有模塊。 – idjaw

+0

爲什麼在這種情況下文檔不夠? – idjaw

回答

4

您可以通過打印出help('modules')做到這一點:

只顯示輸出的幾行,因爲它是大

>>> help('modules') 

Please wait a moment while I gather a list of all available modules... 

IN     aifc    hmac    sf 
__future__   another    html    shelve 
_ast    antigravity   http    shlex 
_bisect    argparse   idlelib    shutil 
_bootlocale   array    imaplib    signal 
_bz2    ast     imghdr    site 
_codecs    asynchat   imp     smtpd 
_codecs_cn   asyncio    importlib   smtplib 
_codecs_hk   asyncore   inspect    sndhdr 
_codecs_iso2022  atexit    io     socket 
_codecs_jp   audioop    ipaddress   socketserver 
_codecs_kr   base64    itertools   something 
_codecs_tw   bdb     json    sqlite3 
_collections  binascii   keyword    sre_compile 
_collections_abc binhex    lib2to3    sre_constants 
_compat_pickle  bisect    linecache   sre_parse 
_compression  builtins   locale    ssl 
_crypt    bz2     logging    stat 
_csv    cProfile   lzma    statistics 
_ctypes    calendar   macpath    string 

你也可以通過搜索匹配的詞縮小。例如,要查找的東西,可能匹配「集合」:

>>> help('modules collections') 

Here is a list of modules whose name or summary contains 'collections'. 
If there are any, enter a module name to get more help. 

_collections - High performance data structures. 
_collections_abc - Abstract Base Classes (ABCs) for collections, according to PEP 3119. 
collections 
collections.__main__ 
collections.abc 
test.test_collections - Unit tests for collections.py. 
test.test_defaultdict - Unit tests for collections.defaultdict. 
pip._vendor.requests.packages.urllib3._collections 

然後,如果你想幫助一個特定的模塊上,以獲取有關它的更多信息,你只需撥打特定的一個幫助:

>>> help('collections')