python内置函数概览

python的内置函数大致可以分为三类(以python3.12版本为基准):


第一类:内置函数(将函数对象传入type方法返回“<class builtin_function_or_method>”)
  1. 数学运算类:abs, divmod, max, min, pow, round, sum

  2. 类型转换与编码类:ascii, bin, chr, hex, oct, ord, repr

  3. 反射与自省类:callable, delattr, dir, getattr, hasattr, setattr, vars

  4. 用于可迭代对象类:aiter, anext, iter, next, len, sorted

  5. 逻辑判断类:all, any

  6. 动态代码执行类:compile, eval, exec

  7. 输入输出类:input, print, open

  8. 调试与工具类:breakpoint, hash, id

  9. 模块与环境操作类:__import__, globals, locals

  10. 特殊用途类:__build_class__, format, isinstance, issubclass


第二类:类似内置函数,实际为内置类(将函数对象传入type方法返回“<class type>”)
  1. 基本数据类型类:bool, bytearray, bytes, complex, float, int, str

  2. 容器类型类:dict, frozenset, list, set, tuple

  3. 迭代与序列工具类:enumerate, filter, map, reversed, zip, range, slice

  4. 面向对象装饰器类:classmethod, staticmethod, property

  5. 元编程与类型类:type, object, super

  6. 内存操作工具类:memoryview


第三类:其他6个(将函数对象传入type方法返回“<class '_sitebuiltins.×××>”)
  1. copyright:type(copyright)为“<class _sitebuiltins._Printer>”

  2. credits:type(credits)为“<class _sitebuiltins._Printer>”

  3. exit:type(exit)为“<class _sitebuiltins.Quitter>”

  4. help:type(help)为“<class _sitebuiltins._Helper>”

  5. license:type(license)为“<class _sitebuiltins._Printer>”

  6. quit:type(quit)为“<class _sitebuiltins.Quitter>”


对于以上这些python的“内置函数”,它们的用法均类似于函数,但实际类型是有区别的,需要注意区分。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值