使用 dir()
使用 dir() 可以查看指定模块中定义的名称,它返回的是一个已排序的字符串列表:
>>> import math # 内置模块 math
>>> dir(math)
['__doc...例如,属性 __name__ 表示模块名称:
>>> math....__name__
'math'
如果没有参数,dir() 会列出当前作用域中的名称:
>>> s = 'Hello'
>>> l = [1, 2, 3]
>>> abs = math.fabs
>>...MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError..., 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range