首页 > 后端开发 > Python教程 > 查看python的可用模块

查看python的可用模块

高洛峰
发布: 2016-10-19 15:00:37
原创
2389 人浏览过

1.这种方式的问题是,只列出当前import进上下文的模块.

进入python命令行.输入以下代码:

$ python
Python 2.7.2 (default, Jan 19 2012, 18:26:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.modules
{&#39;copy_reg&#39;: <module &#39;copy_reg&#39; from &#39;/usr/local/lib/python2.7/copy_reg.pyc&#39;>, &#39;sre_compile&#39;: <module &#39;sre_compile&#39; from &#39;/usr/local/lib/python2.7/sre_compile.pyc&#39;>, &#39;_sre&#39;: <module &#39;_sre&#39; (built-in)>, &#39;encodings&#39;: <module &#39;encodings&#39; from &#39;/usr/local/lib/python2.7/encodings/__init__.pyc&#39;>, &#39;site&#39;: <module &#39;site&#39; from &#39;/usr/local/lib/python2.7/site.pyc&#39;>, &#39;__builtin__&#39;: <module &#39;__builtin__&#39; (built-in)>, &#39;sysconfig&#39;: <module &#39;sysconfig&#39; from &#39;/usr/local/lib/python2.7/sysconfig.pyc&#39;>, &#39;__main__&#39;: <module &#39;__main__&#39; (built-in)>, &#39;encodings.encodings&#39;: None, &#39;abc&#39;: <module &#39;abc&#39; from &#39;/usr/local/lib/python2.7/abc.pyc&#39;>, &#39;posixpath&#39;: <module &#39;posixpath&#39; from &#39;/usr/local/lib/python2.7/posixpath.pyc&#39;>, &#39;_weakrefset&#39;: <module &#39;_weakrefset&#39; from &#39;/usr/local/lib/python2.7/_weakrefset.pyc&#39;>, &#39;errno&#39;: <module &#39;errno&#39; (built-in)>, &#39;encodings.codecs&#39;: None, &#39;sre_constants&#39;: <module &#39;sre_constants&#39; from &#39;/usr/local/lib/python2.7/sre_constants.pyc&#39;>, &#39;re&#39;: <module &#39;re&#39; from &#39;/usr/local/lib/python2.7/re.pyc&#39;>, &#39;_abcoll&#39;: <module &#39;_abcoll&#39; from &#39;/usr/local/lib/python2.7/_abcoll.pyc&#39;>, &#39;types&#39;: <module &#39;types&#39; from &#39;/usr/local/lib/python2.7/types.pyc&#39;>, &#39;_codecs&#39;: <module &#39;_codecs&#39; (built-in)>, &#39;_warnings&#39;: <module &#39;_warnings&#39; (built-in)>, &#39;genericpath&#39;: <module &#39;genericpath&#39; from &#39;/usr/local/lib/python2.7/genericpath.pyc&#39;>, &#39;stat&#39;: <module &#39;stat&#39; from &#39;/usr/local/lib/python2.7/stat.pyc&#39;>, &#39;zipimport&#39;: <module &#39;zipimport&#39; (built-in)>, &#39;encodings.__builtin__&#39;: None, &#39;warnings&#39;: <module &#39;warnings&#39; from &#39;/usr/local/lib/python2.7/warnings.pyc&#39;>, &#39;UserDict&#39;: <module &#39;UserDict&#39; from &#39;/usr/local/lib/python2.7/UserDict.pyc&#39;>, &#39;encodings.utf_8&#39;: <module &#39;encodings.utf_8&#39; from &#39;/usr/local/lib/python2.7/encodings/utf_8.pyc&#39;>, &#39;sys&#39;: <module &#39;sys&#39; (built-in)>, &#39;codecs&#39;: <module &#39;codecs&#39; from &#39;/usr/local/lib/python2.7/codecs.pyc&#39;>, &#39;readline&#39;: <module &#39;readline&#39; from &#39;/usr/local/lib/python2.7/lib-dynload/readline.so&#39;>, &#39;os.path&#39;: <module &#39;posixpath&#39; from &#39;/usr/local/lib/python2.7/posixpath.pyc&#39;>, &#39;signal&#39;: <module &#39;signal&#39; (built-in)>, &#39;traceback&#39;: <module &#39;traceback&#39; from &#39;/usr/local/lib/python2.7/traceback.pyc&#39;>, &#39;linecache&#39;: <module &#39;linecache&#39; from &#39;/usr/local/lib/python2.7/linecache.pyc&#39;>, &#39;posix&#39;: <module &#39;posix&#39; (built-in)>, &#39;encodings.aliases&#39;: <module &#39;encodings.aliases&#39; from &#39;/usr/local/lib/python2.7/encodings/aliases.pyc&#39;>, &#39;exceptions&#39;: <module &#39;exceptions&#39; (built-in)>, &#39;sre_parse&#39;: <module &#39;sre_parse&#39; from &#39;/usr/local/lib/python2.7/sre_parse.pyc&#39;>, &#39;os&#39;: <module &#39;os&#39; from &#39;/usr/local/lib/python2.7/os.pyc&#39;>, &#39;_weakref&#39;: <module &#39;_weakref&#39; (built-in)>}
2.还可以在python命令行下获取在线帮助:
>>> help()
Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".


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

/usr/local/lib/python2.7/site-packages/nltk/app/__init__.py:30: UserWarning: nltk.app package not loaded (please install Tkinter library).
 warnings.warn("nltk.app package not loaded "
/usr/local/lib/python2.7/site-packages/nltk/draw/__init__.py:16: UserWarning: nltk.draw package not loaded (please install Tkinter library).
 warnings.warn("nltk.draw package not loaded "
/usr/local/lib/python2.7/site-packages/twisted/words/im/__init__.py:8: UserWarning: twisted.im will be undergoing a rewrite at some point in the future.
 warnings.warn("twisted.im will be undergoing a rewrite at some point in the future.")
ArgImagePlugin      _LWPCookieJar       dumbdbm             readability
BaseHTTPServer      _MozillaCookieJar   dummy_thread        readline
Bastion             __builtin__         dummy_threading     redis
BdfFontFile         __future__          easy_install        repr
BeautifulSoup       _abcoll             email               resource
BeautifulSoupTests  _ast                encodings           rexec
BmpImagePlugin      _bisect             engine              rfc822
BufrStubImagePlugin _codecs             errno               rlcompleter
CDROM               _codecs_cn          exceptions          robotparser
CGIHTTPServer       _codecs_hk          ext                 runpy
Canvas              _codecs_iso2022     fcntl               sched
ConfigParser        _codecs_jp          filecmp             scrapy
ContainerIO         _codecs_kr          fileinput           scrapyd
Cookie              _codecs_tw          fnmatch             select
Crypto              _collections        formatter           server
CurImagePlugin      _csv                fpformat            sets
DLFCN               _ctypes             fractions           setuptools
DcxImagePlugin      _ctypes_test        ftplib              sgmllib
Dialog              _curses             functools           sha
DocXMLRPCServer     _curses_panel       future_builtins     shelve
EpsImagePlugin      _elementtree        gc                  shlex
ExifTags            _functools          genericpath         shutil
FileDialog          _hashlib            getopt              signal
FitsStubImagePlugin _heapq              getpass             site
FixTk               _hotshot            gettext             six
FliImagePlugin      _imaging            glob                smtpd
FontFile            _imagingcms         grp                 smtplib
FpxImagePlugin      _imagingft          gzip                sndhdr
GbrImagePlugin      _imagingmath        hashlib             socket
GdImageFile         _io                 heapq               spwd
GifImagePlugin      _json               hmac                sql
GimpGradientFile    _locale             hotshot             sqlalchemy
GimpPaletteFile     _lsprof             htmlentitydefs      sqlite3
GribStubImagePlugin _md5                htmllib             sre
HTMLParser          _multibytecodec     httplib             sre_compile
Hdf5StubImagePlugin _multiprocessing    idlelib             sre_constants
IN                  _mysql              ihooks              sre_parse
IcnsImagePlugin     _mysql_exceptions   imaplib             ssl
IcoImagePlugin      _pyio               imghdr              stat
ImImagePlugin       _random             imp                 statvfs
Image               _sha                importlib           string
ImageChops          _sha256             imputil             stringold
ImageCms            _sha512             inspect             stringprep
ImageColor          _socket             io                  strop
ImageDraw           _sre                itertools           struct
ImageDraw2          _ssl                json                subprocess
ImageEnhance        _strptime           keyword             sunau
ImageFile           _struct             lib2to3             sunaudio
ImageFileIO         _symtable           linecache           symbol
ImageFilter         _testcapi           linuxaudiodev       symtable
ImageFont           _threading_local    locale              sys
ImageGL             _warnings           logging             sysconfig
ImageGrab           _weakref            lxml                syslog
ImageMath           _weakrefset         macpath             tabnanny
ImageMode           _yappi              macurl2path         tarfile
ImageOps            abc                 mailbox             telnetlib
ImagePalette        aifc                mailcap             tempfile
ImagePath           antigravity         markupbase          termios
ImageQt             anydbm              marshal             test
ImageSequence       argparse            math                tests
ImageShow           array               mcrypt              textwrap
ImageStat           ast                 md5                 this
ImageTk             asynchat            mhlib               thread
ImageTransform      asyncore            mimetools           threading
ImageWin            atexit              mimetypes           thrift
ImtImagePlugin      audiodev            mimify              time
IptcImagePlugin     audioop             mmap                timeit
JpegImagePlugin     base64              modulefinder        tkColorChooser
McIdasImagePlugin   bdb                 multifile           tkCommonDialog
MicImagePlugin      binascii            multiprocessing     tkFileDialog
MimeWriter          binhex              mutex               tkFont
MpegImagePlugin     bisect              netrc               tkMessageBox
MspImagePlugin      bsddb               new                 tkSimpleDialog
MySQLdb             bz2file             nis                 toaiff
OleFileIO           cPickle             nltk                token
OpenSSL             cProfile            nntplib             tokenize
PIL                 cStringIO           ntpath              tornado
PSDraw              calendar            nturl2path          trace
PaletteFile         cgi                 numbers             traceback
PalmImagePlugin     cgitb               opcode              transport
PcdImagePlugin      chardet             operator            ttk
PcfFontFile         chunk               optparse            tty
PcxImagePlugin      cmath               orm                 turtle
PdfImagePlugin      cmd                 os                  twisted
PixarImagePlugin    code                os2emxpath          types
PngImagePlugin      codecs              ossaudiodev         unicodedata
PpmImagePlugin      codeop              parser              unittest
PsdImagePlugin      collections         pdb                 urllib
Queue               colorsys            pickle              urllib2
ScrolledText        command             pickletools         urlparse
SgiImagePlugin      commands            pip                 user
SimpleDialog        compileall          pipes               util
SimpleHTTPServer    compiler            pkg_resources       uu
SimpleXMLRPCServer  connectors          pkgutil             uuid
SocketServer        constants           platform            virtualenv
SpiderImagePlugin   contextlib          plistlib            virtualenv_support
StringIO            cookielib           popen2              w3lib
SunImagePlugin      copy                poplib              warnings
TYPES               copy_reg            posix               wave
TarIO               crypt               posixfile           weakref
TgaImagePlugin      csv                 posixpath           web
TiffImagePlugin     ctypes              pprint              webbrowser
TiffTags            curses              profile             whichdb
Tix                 databases           protocol            wsgiref
Tkconstants         datetime            pstats              xdrlib
Tkdnd               dateutil            pty                 xml
Tkinter             dbhash              pwd                 xmllib
UserDict            decimal             py_compile          xmlrpclib
UserList            dialects            pyclbr              xxsubtype
UserString          difflib             pydoc               yaml
WalImageFile        dircache            pydoc_data          yappi
WmfImagePlugin      dis                 pyexpat             zipfile
XVThumbImagePlugin  distutils           quopri              zipimport
XbmImagePlugin      django              random              zlib
XpmImagePlugin      doctest             re                  zope

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".
登录后复制


相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板