美文网首页
python内置函数 2021-01-28

python内置函数 2021-01-28

作者: 看不到任何出路 | 来源:发表于2021-03-07 23:00 被阅读0次

builtins是 Python 的一个内建模块。

解释器执行时builtins模块会被自动导入,相当于隐式执行了:

from builtins import *

例:open()函数的全名其实是builtins.open()

我们常用的print()help()range()set()... 等其实都是builtins模块中的函数/类

Built-in Functions

abs()           dict()          help()          min()           setattr()
all()           dir()           hex()           next()          slice()
any()           divmod()        id()            object()        sorted()
ascii()         enumerate()     input()         oct()           staticmethod()
bin()           eval()          int()           open()          str()
bool()          exec()          isinstance()    ord()           sum()
bytearray()     filter()        issubclass()    pow()           super()
bytes()         float()         iter()          print()         tuple()
callable()      format()        len()           property()      type()
chr()           frozenset()     list()          range()         vars()
classmethod()   getattr()       locals()        repr()          zip()
compile()       globals()       map()           reversed()      __import__()
complex()       hasattr()       max()           round()  
delattr()       hash()          memoryview()    set()   

python内置函数

  • zip():zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的对象,这样做的好处是节约了不少的内存。我们可以使用 list() 转换来输出列表。如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表。

相关文章

网友评论

      本文标题:python内置函数 2021-01-28

      本文链接:https://www.haomeiwen.com/subject/paixtltx.html