新聞中心
bif(built-in functions)顧名思義,就是Erlang內(nèi)建函數(shù)。它們通常用來完成那此無法用Erlang完成的任務。比如將列表轉(zhuǎn)換為元組或者獲取當前的時間和日期。完成這些操作的函數(shù),我們稱之為BIF。python中提供了大量的內(nèi)置功能函數(shù),這就意味著你可以少些很多的代碼。Python3中共提供了72個BIF。

成都創(chuàng)新互聯(lián)公司網(wǎng)站建設服務商,為中小企業(yè)提供成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營銷網(wǎng)站建設服務,網(wǎng)站設計,網(wǎng)站托管等一站式綜合服務型公司,專業(yè)打造企業(yè)形象網(wǎng)站,讓您在眾多競爭對手中脫穎而出成都創(chuàng)新互聯(lián)公司。
我們可以在python或IDLE shell中,輸入dir(__builtins__)級可看到python的內(nèi)置方法列表,"builtins"的前后都是兩個下劃線,shell會給出一個龐大的列表,如下:
['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', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', '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', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
要查看某個BIF是干什么的,可以在shell中鍵入help(方法名),如:help(isinstance)就會得到這個BIF的功能描述。如下:
>>> help(isinstance) Help on built-in function isinstance in module builtins: isinstance(...) isinstance(object, class-or-type-or-tuple) -> bool Return whether an object is an instance of a class or of a subclass thereof. With a type as second argument, return whether that is the object's type. The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for isinstance(x, A) or isinstance(x, B) or ... (etc.).
就可以得到isinstance函數(shù)的介紹和使用方法。
python學習網(wǎng),大量的免費python視頻教程,歡迎在線學習!
本文標題:創(chuàng)新互聯(lián)Python教程:python3有多少個bif
轉(zhuǎn)載源于:http://m.fisionsoft.com.cn/article/dheecgc.html


咨詢
建站咨詢
