python文档

2023-01-31 03:01:04 python 文档

#形式 # 角色

#抓取对象内可用的所有属性列表的简单方式

import random

print(dir(random))

#['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'Random', 'SG_MAGICCONST',
#'SystemRandom', 'TWOPI', '_BuiltinMethodType', '_MethodType', '_Sequence',
#'_Set', 'all', 'builtins', 'cached', 'doc', 'file',
#'loader', 'name', 'package', 'spec', '_acos', '_bisect',
#'_ceil', '_cos', '_e', '_exp', '_inst', '_itertools', '_log', '_pi', '_random',
#'_sha512', '_sin', '_sqrt', '_test', '_test_generator', '_urandom', '_warn',
#'betavariate', 'choice', 'choices', 'expovariate', 'gammavariate', 'gauss',
#'getrandbits', 'getstate', 'lognORMvariate', 'normalvariate', 'paretovariate',
#'randint', 'random', 'randrange', 'sample', 'seed', 'setstate', 'shuffle',
#'triangular', 'uniform', 'vonmisesvariate', 'weibullvariate']

print(dir('1') == dir(''))

#在可执行代码执行前,会自动封装这个字符串,也就是文档字符串,使他成为doc

#内置文档字符串可以用__doc_来查看
import sys
#print(sys.doc)

#...

print(sys.getrefcount.doc)

#getrefcount(object) -> integer

#Return the reference count of object. The count returned is generally
#one higher than you might expect, because it includes the (temporary)
#reference as an argument to getrefcount().

print(int.doc)

#help函数

print(help(int))

# 会影响其他变量

相关文章