查看python的可用模块

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
{‘copy_reg’: , ‘sre_compile’: , ‘_sre’: , ‘encodings’: , ‘site’: , ‘__builtin__’: , ‘sysconfig’: , ‘__main__’: , ‘encodings.encodings’: none, ‘abc’: , ‘posixpath’: , ‘_weakrefset’: , ‘errno’: , ‘encodings.codecs’: none, ‘sre_constants’: , ‘re’: , ‘_abcoll’: , ‘types’: , ‘_codecs’: , ‘_warnings’: , ‘genericpath’: , ‘stat’: , ‘zipimport’: , ‘encodings.__builtin__’: none, ‘warnings’: , ‘userdict’: , ‘encodings.utf_8’: , ‘sys’: , ‘codecs’: , ‘readline’: , ‘os.path’: , ‘signal’: , ‘traceback’: , ‘linecache’: , ‘posix’: , ‘encodings.aliases’: , ‘exceptions’: , ‘sre_parse’: , ‘os’: , ‘_weakref’: }
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”.

Posted in 未分类

发表评论