0

0

查看python的可用模块

高洛峰

高洛峰

发布时间:2016-10-19 15:00:37

|

2558人浏览过

|

来源于php中文网

原创

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': <module>, 'sre_compile': <module>, '_sre': <module>, 'encodings': <module>, 'site': <module>, '__builtin__': <module>, 'sysconfig': <module>, '__main__': <module>, 'encodings.encodings': None, 'abc': <module>, 'posixpath': <module>, '_weakrefset': <module>, 'errno': <module>, 'encodings.codecs': None, 'sre_constants': <module>, 're': <module>, '_abcoll': <module>, 'types': <module>, '_codecs': <module>, '_warnings': <module>, 'genericpath': <module>, 'stat': <module>, 'zipimport': <module>, 'encodings.__builtin__': None, 'warnings': <module>, 'UserDict': <module>, 'encodings.utf_8': <module>, 'sys': <module>, 'codecs': <module>, 'readline': <module>, 'os.path': <module>, 'signal': <module>, 'traceback': <module>, 'linecache': <module>, 'posix': <module>, 'encodings.aliases': <module>, 'exceptions': <module>, 'sre_parse': <module>, 'os': <module>, '_weakref': <module>}
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".</module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module></module>


V63积分商城 FOR DZ GBK
V63积分商城 FOR DZ GBK

v63积分商城特色功能:支持三种物品类型的发放1.实物:实物领取需要填写收货信息:2.虚拟:可以自定义用户领取需要填写的信息3.卡密:自动发放,后台能够查看编辑卡密状态支持三种种物品发放方式1.兑换:2.拍卖3. 抽奖兑换拍卖信息可以以帖子的形式自动发布当设定了“兑换拍卖自动发帖版块“ ID时,发布商品会自动在改ID版块生成帖子用户兑换或者出价后都会以跟帖的

下载

相关文章

python速学教程(入门到精通)
python速学教程(入门到精通)

python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
Golang 测试体系与代码质量保障:工程级可靠性建设
Golang 测试体系与代码质量保障:工程级可靠性建设

Go语言测试体系与代码质量保障聚焦于构建工程级可靠性系统。本专题深入解析Go的测试工具链(如go test)、单元测试、集成测试及端到端测试实践,结合代码覆盖率分析、静态代码扫描(如go vet)和动态分析工具,建立全链路质量监控机制。通过自动化测试框架、持续集成(CI)流水线配置及代码审查规范,实现测试用例管理、缺陷追踪与质量门禁控制,确保代码健壮性与可维护性,为高可靠性工程系统提供质量保障。

6

2026.02.28

Golang 工程化架构设计:可维护与可演进系统构建
Golang 工程化架构设计:可维护与可演进系统构建

Go语言工程化架构设计专注于构建高可维护性、可演进的企业级系统。本专题深入探讨Go项目的目录结构设计、模块划分、依赖管理等核心架构原则,涵盖微服务架构、领域驱动设计(DDD)在Go中的实践应用。通过实战案例解析接口抽象、错误处理、配置管理、日志监控等关键工程化技术,帮助开发者掌握构建稳定、可扩展Go应用的最佳实践方法。

6

2026.02.28

Golang 性能分析与运行时机制:构建高性能程序
Golang 性能分析与运行时机制:构建高性能程序

Go语言以其高效的并发模型和优异的性能表现广泛应用于高并发、高性能场景。其运行时机制包括 Goroutine 调度、内存管理、垃圾回收等方面,深入理解这些机制有助于编写更高效稳定的程序。本专题将系统讲解 Golang 的性能分析工具使用、常见性能瓶颈定位及优化策略,并结合实际案例剖析 Go 程序的运行时行为,帮助开发者掌握构建高性能应用的关键技能。

8

2026.02.28

Golang 并发编程模型与工程实践:从语言特性到系统性能
Golang 并发编程模型与工程实践:从语言特性到系统性能

本专题系统讲解 Golang 并发编程模型,从语言级特性出发,深入理解 goroutine、channel 与调度机制。结合工程实践,分析并发设计模式、性能瓶颈与资源控制策略,帮助将并发能力有效转化为稳定、可扩展的系统性能优势。

14

2026.02.27

Golang 高级特性与最佳实践:提升代码艺术
Golang 高级特性与最佳实践:提升代码艺术

本专题深入剖析 Golang 的高级特性与工程级最佳实践,涵盖并发模型、内存管理、接口设计与错误处理策略。通过真实场景与代码对比,引导从“可运行”走向“高质量”,帮助构建高性能、可扩展、易维护的优雅 Go 代码体系。

17

2026.02.27

Golang 测试与调试专题:确保代码可靠性
Golang 测试与调试专题:确保代码可靠性

本专题聚焦 Golang 的测试与调试体系,系统讲解单元测试、表驱动测试、基准测试与覆盖率分析方法,并深入剖析调试工具与常见问题定位思路。通过实践示例,引导建立可验证、可回归的工程习惯,从而持续提升代码可靠性与可维护性。

2

2026.02.27

漫蛙app官网链接入口
漫蛙app官网链接入口

漫蛙App官网提供多条稳定入口,包括 https://manwa.me、https

130

2026.02.27

deepseek在线提问
deepseek在线提问

本合集汇总了DeepSeek在线提问技巧与免登录使用入口,助你快速上手AI对话、写作、分析等功能。阅读专题下面的文章了解更多详细内容。

8

2026.02.27

AO3官网直接进入
AO3官网直接进入

AO3官网最新入口合集,汇总2026年可用官方及镜像链接,助你快速稳定访问Archive of Our Own平台。阅读专题下面的文章了解更多详细内容。

208

2026.02.27

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
最新Python教程 从入门到精通
最新Python教程 从入门到精通

共4课时 | 22.5万人学习

Django 教程
Django 教程

共28课时 | 4.6万人学习

SciPy 教程
SciPy 教程

共10课时 | 1.8万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号