版本:Python 3.7.4
Python自动加载的模块有如下7个:
C:\Users\Administrator>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
>>>
导入builtins模块后,其实自动加载的__builtins__模块和手动导入的builtins模块是同一个模块。
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'builtins']
>>>
使用help命令可以看到相同的输出内容,help(__builtins__) 和 help(builtins)。
内容主要有下面6各部分,分别是NAME,DESCRIPTION,CLASSES,FUNCTIONS,DATA,FILE
1.NAME
builtins - Built-in functions, exceptions, and other objects.
2.DESCRIPTION
Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.
3.CLASSES (共计90个类)
3.1类继承树
object
|-BaseException
| |-Exception
| | |-ArithmeticError
| | | |-FloatingPointError
| | | |-OverflowError
| | | \ZeroDivisionError
| | |-AssertionError
| | |-AttributeError
| | |-BufferError
| | |-EOFError
| | |-ImportError
| | | \ModuleNotFoundError
| | |-LookupError
| | | |-IndexError
| | | \KeyError
| | |-MemoryError
| | |-NameError
| | | \UnboundLocalError
| | |-OSError
| | | |-BlockingIOError
| | | |-ChildProcessError
| | | |-ConnectionError
| | | | |-BrokenPipeError
| | | | |-ConnectionAbortedError
| | | | |-ConnectionRefusedError
| | | | \ConnectionResetError
| | | |-FileExistsError
| | | |-FileNotFoundError
| | | |-InterruptedError
| | | |-IsADirectoryError
| | | |-NotADirectoryError
| | | |-PermissionError
| | | |-ProcessLookupError
| | | \TimeoutError
| | |-ReferenceError
| | |-RuntimeError
| | | |-NotImplementedError
| | | \RecursionError
| | |-StopAsyncIteration
| | |-StopIteration
| | |-SyntaxError
| | | \IndentationError
| | | \TabError
| | |-SystemError
| | |-TypeError
| | |-ValueError
| | | |-UnicodeError
| | | |-UnicodeDecodeError
| | | |-UnicodeEncodeError
| | | \UnicodeTranslateError
| | |-Warning
| | | |-BytesWarning
| | | |-DeprecationWarning
| | | |-FutureWarning
| | | |-ImportWarning
| | | |-PendingDeprecationWarning
| | | |-ResourceWarning
| | | |-RuntimeWarning
| | | |-SyntaxWarning
| | | |-UnicodeWarni