python怎么看模块方法_【Python】查看模块及模块包含的方法

1、dir:查看模板中的方法

import itertools

print(dir(itertools))

结果

[’_doc_’, ‘_loader_’, ‘_name_’, ‘_package_’, ‘_spec_’,

‘_grouper’, ‘_tee’, ‘_tee_dataobject’, ‘accumulate’, ‘chain’,

‘combinations’, ‘combinations_with_replacement’, ‘compress’, ‘count’,

‘cycle’, ‘dropwhile’, ‘filterfalse’, ‘groupby’, ‘islice’,

‘permutations’, ‘product’, ‘repeat’, ‘starmap’, ‘takewhile’, ‘tee’,

‘zip_longest’]

2、help:查看模块或方法的内容

import itertools

print(help(itertools.product()))

结果

95c05a4d47703420d4d81c429628405e.png

另外一种方法:

cmd进入到python后,输入help()进入交互式,然后直接输入模块或是方法

ede7c3af7cfeadcd4e0bf9db2ef85230.png

3、sys.builtin_module_names查看内置模块

import sys

print(sys.builtin_module_names)

结果:

(’_ast’, ‘_bisect’, ‘_blake2’, ‘_codecs’, ‘_codecs_cn’, ‘_codecs_hk’,

‘_codecs_iso2022’, ‘_codecs_jp’, ‘_codecs_kr’, ‘_codecs_tw’,

‘_collections’, ‘_csv’, ‘_datetime’, ‘_functools’, ‘_heapq’, ‘_imp’,

‘_io’, ‘_json’, ‘_locale’, ‘_lsprof’, ‘_md5’, ‘_multibytecodec’,

‘_opcode’, ‘_operator’, ‘_pickle’, ‘_random’, ‘_sha1’, ‘_sha256’,

‘_sha3’, ‘_sha512’, ‘_signal’, ‘_sre’, ‘_stat’, ‘_string’, ‘_struct’,

‘_symtable’, ‘_thread’, ‘_tracemalloc’, ‘_warnings’, ‘_weakref’,

‘_winapi’, ‘array’, ‘atexit’, ‘audioop’, ‘binascii’, ‘builtins’,

‘cmath’, ‘errno’, ‘faulthandler’, ‘gc’, ‘itertools’, ‘marshal’,

‘math’, ‘mmap’, ‘msvcrt’, ‘nt’, ‘parser’, ‘sys’, ‘time’, ‘winreg’,

‘xxsubtype’, ‘zipimport’, ‘zlib’)

4、模块是内置还是外置

07036f4cf3bc7ea6948898bafd83b055.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值