当前位置:编程学习 > python >>

python查看可用模块

总结一下:
 
1.这种方式的问题是,只列出当前import进上下文的模块.
进入python命令行.输入以下代码: 
 
 import sys 
 
 
 sys.modules 
 
结果类似:
{‘copy_reg’: <module ‘copy_reg’ from ‘/usr/lib/python2.7/copy_reg.pyc’>, ‘sre_compile’: <module ‘sre_compile’ from ‘/usr/lib/python2.7/sre_compile.pyc’>, ‘_sre’: <module ‘_sre’ (built-in)>, ‘encodings’: <module ‘encodings’ from ‘/usr/lib/python2.7/encodings/__init__.pyc’>, ‘site’: <module ‘site’ from ‘/usr/lib/python2.7/site.pyc’>, ‘__builtin__’: <module ‘__builtin__’ (built-in)>, ‘sysconfig’: <module ‘sysconfig’ from ‘/usr/lib/python2.7/sysconfig.pyc’>, ‘__main__’: <module ‘__main__’ (built-in)>, ‘encodings.encodings’: None, ‘abc’: <module ‘abc’ from ‘/usr/lib/python2.7/abc.pyc’>, ‘posixpath’: <module ‘posixpath’ from ‘/usr/lib/python2.7/posixpath.pyc’>, ‘_weakrefset’: <module ‘_weakrefset’ from ‘/usr/lib/python2.7/_weakrefset.pyc’>, ‘errno’: <module ‘errno’ (built-in)>, ‘encodings.codecs’: None, ‘sre_constants’: <module ‘sre_constants’ from ‘/usr/lib/python2.7/sre_constants.pyc’>, ‘re’: <module ‘re’ from ‘/usr/lib/python2.7/re.pyc’>, ‘_abcoll’: <module ‘_abcoll’ from ‘/usr/lib/python2.7/_abcoll.pyc’>, ‘types’: <module ‘types’ from ‘/usr/lib/python2.7/types.pyc’>, ‘_codecs’: <module ‘_codecs’ (built-in)>, ‘_warnings’: <module ‘_warnings’ (built-in)>, ‘genericpath’: <module ‘genericpath’ from ‘/usr/lib/python2.7/genericpath.pyc’>, ‘stat’: <module ‘stat’ from ‘/usr/lib/python2.7/stat.pyc’>, ‘zipimport’: <module ‘zipimport’ (built-in)>, ‘encodings.__builtin__’: None, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python2.7/warnings.pyc’>, ‘UserDict’: <module ‘UserDict’ from ‘/usr/lib/python2.7/UserDict.pyc’>, ‘encodings.utf_8′: <module ‘encodings.utf_8′ from ‘/usr/lib/python2.7/encodings/utf_8.pyc’>, ‘sys’: <module ‘sys’ (built-in)>, ‘codecs’: <module ‘codecs’ from ‘/usr/lib/python2.7/codecs.pyc’>, ‘readline’: <module ‘readline’ from ‘/usr/lib/python2.7/lib-dynload/readline.so’>, ‘os.path’: <module ‘posixpath’ from ‘/usr/lib/python2.7/posixpath.pyc’>, ‘sitecustomize’: <module ‘sitecustomize’ from ‘/usr/lib/python2.7/sitecustomize.pyc’>, ‘signal’: <module ‘signal’ (built-in)>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python2.7/traceback.pyc’>, ‘apport_python_hook’: <module ‘apport_python_hook’ from ‘/usr/lib/python2.7/dist-packages/apport_python_hook.pyc’>, ‘linecache’: <module ‘linecache’ from ‘/usr/lib/python2.7/linecache.pyc’>, ‘posix’: <module ‘posix’ (built-in)>, ‘encodings.aliases’: <module ‘encodings.aliases’ from ‘/usr/lib/python2.7/encodings/aliases.pyc’>, ‘exceptions’: <module ‘exceptions’ (built-in)>, ‘sre_parse’: <module ‘sre_parse’ from ‘/usr/lib/python2.7/sre_parse.pyc’>, ‘os’: <module ‘os’ from ‘/usr/lib/python2.7/os.pyc’>, ‘_weakref’: <module ‘_weakref’ (built-in)>}
 
2.在python命令行下输入: 
 
 help() 
 
 
 modules 
python查看可用模块 - InSun - Minghacker is Insun

补充:Web开发 , Python ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,