1. The problem with this method is that only the modules currently imported into the context are listed.
Enter the python command line. Enter the following code:
$ 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 {'copy_reg': <module 'copy_reg' from '/usr/local/lib/python2.7/copy_reg.pyc'>, 'sre_compile': <module 'sre_compile' from '/usr/local/lib/python2.7/sre_compile.pyc'>, '_sre': <module '_sre' (built-in)>, 'encodings': <module 'encodings' from '/usr/local/lib/python2.7/encodings/__init__.pyc'>, 'site': <module 'site' from '/usr/local/lib/python2.7/site.pyc'>, '__builtin__': <module '__builtin__' (built-in)>, 'sysconfig': <module 'sysconfig' from '/usr/local/lib/python2.7/sysconfig.pyc'>, '__main__': <module '__main__' (built-in)>, 'encodings.encodings': None, 'abc': <module 'abc' from '/usr/local/lib/python2.7/abc.pyc'>, 'posixpath': <module 'posixpath' from '/usr/local/lib/python2.7/posixpath.pyc'>, '_weakrefset': <module '_weakrefset' from '/usr/local/lib/python2.7/_weakrefset.pyc'>, 'errno': <module 'errno' (built-in)>, 'encodings.codecs': None, 'sre_constants': <module 'sre_constants' from '/usr/local/lib/python2.7/sre_constants.pyc'>, 're': <module 're' from '/usr/local/lib/python2.7/re.pyc'>, '_abcoll': <module '_abcoll' from '/usr/local/lib/python2.7/_abcoll.pyc'>, 'types': <module 'types' from '/usr/local/lib/python2.7/types.pyc'>, '_codecs': <module '_codecs' (built-in)>, '_warnings': <module '_warnings' (built-in)>, 'genericpath': <module 'genericpath' from '/usr/local/lib/python2.7/genericpath.pyc'>, 'stat': <module 'stat' from '/usr/local/lib/python2.7/stat.pyc'>, 'zipimport': <module 'zipimport' (built-in)>, 'encodings.__builtin__': None, 'warnings': <module 'warnings' from '/usr/local/lib/python2.7/warnings.pyc'>, 'UserDict': <module 'UserDict' from '/usr/local/lib/python2.7/UserDict.pyc'>, 'encodings.utf_8': <module 'encodings.utf_8' from '/usr/local/lib/python2.7/encodings/utf_8.pyc'>, 'sys': <module 'sys' (built-in)>, 'codecs': <module 'codecs' from '/usr/local/lib/python2.7/codecs.pyc'>, 'readline': <module 'readline' from '/usr/local/lib/python2.7/lib-dynload/readline.so'>, 'os.path': <module 'posixpath' from '/usr/local/lib/python2.7/posixpath.pyc'>, 'signal': <module 'signal' (built-in)>, 'traceback': <module 'traceback' from '/usr/local/lib/python2.7/traceback.pyc'>, 'linecache': <module 'linecache' from '/usr/local/lib/python2.7/linecache.pyc'>, 'posix': <module 'posix' (built-in)>, 'encodings.aliases': <module 'encodings.aliases' from '/usr/local/lib/python2.7/encodings/aliases.pyc'>, 'exceptions': <module 'exceptions' (built-in)>, 'sre_parse': <module 'sre_parse' from '/usr/local/lib/python2.7/sre_parse.pyc'>, 'os': <module 'os' from '/usr/local/lib/python2.7/os.pyc'>, '_weakref': <module '_weakref' (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".