• 技术文章 >Python技术 >Python基础教程

    python如何查看内置函数

    爱喝马黛茶的安东尼爱喝马黛茶的安东尼2019-09-23 13:52:59原创4373

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

    举例python版本:

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

    1

    dir(__builtin__)

    相关推荐:《Python基础教程

    输出一个列表:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    40

    41

    42

    43

    44

    45

    46

    47

    48

    49

    50

    51

    52

    53

    54

    55

    56

    57

    58

    59

    60

    61

    62

    63

    64

    65

    66

    67

    68

    69

    70

    71

    72

    73

    74

    75

    76

    77

    78

    79

    80

    81

    82

    83

    84

    85

    86

    87

    88

    89

    90

    91

    92

    93

    94

    95

    96

    97

    98

    99

    100

    101

    102

    103

    104

    105

    106

    107

    108

    109

    110

    111

    112

    113

    114

    115

    116

    117

    118

    119

    120

    121

    122

    123

    124

    125

    126

    127

    128

    129

    130

    131

    132

    133

    134

    135

    136

    137

    138

    139

    140

    141

    142

    143

    144

    145

    146

    147

    148

    149

    150

    151

    152

    153

    154

    155

    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的内置函数名。

    进一步查看内置函数的用法可以:

    1

    2

    # help(内置函数名)

    help(list)

    专题推荐:python 查看 内置函数
    上一篇:python函数和c的区别有哪些 下一篇:python脚本如何测试手机

    相关文章推荐

    • 一分钟学会如何查看Python内置函数的用法及其源码• python内置函数在哪• python 重载内置函数吗

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网