如何通过命令查看python中的所有内置函数和内置常量

如何通过命令查看python中的所有内置函数和内置常量

举例python版本:

利用python中的语句输出python中的所有内置函数及内置常量名:

	dir(__builtin__)

输出一个列表:

	In [1]: dir(__builtin__)                                                       
	Out[1]: 
	['ArithmeticError',
	 'AssertionError',
	 'AttributeError',
	 'BaseException',
	 'BlockingIOError',
	 'BrokenPipeError',
	 'BufferError',
	 'BytesWarning',
	 'ChildProcessError',
	 'ConnectionAbortedError',
	 'ConnectionError',
	 'ConnectionRefusedError',
	 'ConnectionResetError',
	 'DeprecationWarning',
	 'EOFError',
	 'Ellipsis',
	 'EnvironmentError',
	 'Exception',
	 'False',
	 'FileExistsError',
	 'FileNotFoundError',
	 'FloatingPointError',
	 'FutureWarning',
	 'GeneratorExit',
	 'IOError',
	 'ImportError',
	 'ImportWarning',
	 'IndentationError',
	 'IndexError',
	 'InterruptedError',
	 'IsADirectoryError',
	 'KeyError',
	 'KeyboardInterrupt',
	 'LookupError',
	 'MemoryError',
	 'ModuleNotFoundError',
	 'NameError',
	 'None',
	 'NotADirectoryError',
	 'NotImplemented',
	 'NotImplementedError',
	 'OSError',
	 'OverflowError',
	 'PendingDeprecationWarning',
	 'PermissionError',
	 'ProcessLookupError',
	 'RecursionError',
	 'ReferenceError',
	 'ResourceWarning',
	 'RuntimeError',
	 'RuntimeWarning',
	 'StopAsyncIteration',
	 'StopIteration',
	 'SyntaxError',
	 'SyntaxWarning',
	 'SystemError',
	 'SystemExit',
	 'TabError',
	 'TimeoutError',
	 'True',
	 'TypeError',
	 'UnboundLocalError',
	 'UnicodeDecodeError',
	 'UnicodeEncodeError',
	 'UnicodeError',
	 'UnicodeTranslateError',
	 'UnicodeWarning',
	 'UserWarning',
	 'ValueError',
	 'Warning',
	 'ZeroDivisionError',
	 '__IPYTHON__',
	 '__build_class__',
	 '__debug__',
	 '__doc__',
	 '__import__',
	 '__loader__',
	 '__name__',
	 '__package__',
	 '__spec__',
	 'abs',
	 'all',
	 'any',
	 'ascii',
	 'bin',
	 'bool',
	 'breakpoint',
	 'bytearray',
	 'bytes',
	 'callable',
	 'chr',
	 'classmethod',
	 'compile',
	 'complex',
	 'copyright',
	 'credits',
	 'delattr',
	 'dict',
	 'dir',
	 'display',
	 'divmod',
	 'enumerate',
	 'eval',
	 'exec',
	 'filter',
	 'float',
	 'format',
	 'frozenset',
	 'get_ipython',
	 'getattr',
	 'globals',
	 'hasattr',
	 'hash',
	 'help',
	 'hex',
	 'id',
	 'input',
	 'int',
	 'isinstance',
	 'issubclass',
	 'iter',
	 'len',
	 'license',
	 'list',
	 'locals',
	 'map',
	 'max',
	 'memoryview',
	 'min',
	 'next',
	 'object',
	 'oct',
	 'open',
	 'ord',
	 'pow',
	 'print',
	 'property',
	 'range',
	 'repr',
	 'reversed',
	 'round',
	 'set',
	 'setattr',
	 'slice',
	 'sorted',
	 'staticmethod',
	 'str',
	 'sum',
	 'super',
	 'tuple',
	 'type',
	 'vars',
	 'zip']

大写字母开头的是python的内置常量名,小写字母开头的是python的内置函数名。
进一步查看内置函数的用法可以:

	# help(内置函数名)
	help(list)

ps:
本人热爱图灵,热爱中本聪,热爱V神,热爱一切被梨花照过的姑娘。
以下是我个人的公众号,如果有技术问题可以关注我的公众号来跟我交流。
同时我也会在这个公众号上每周更新我的原创文章,喜欢的小伙伴或者老伙计可以支持一下!
如果需要转发,麻烦注明作者。十分感谢!
后现代泼痞浪漫主义奠基人
公众号名称:后现代泼痞浪漫主义奠基人

发布了49 篇原创文章 · 获赞 23 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/michael_wgy_/article/details/93978410