Python内置函数一览表

为了提高程序员的开发效率,Python 提供了很多可以直接拿来用的函数(初学者可以先理解为方法),每个函数都可以帮助程序员实现某些具体的功能。

举个例子,在 Python 2.x 中 print 只是一个关键字,但在 Python 3.x 中,print 是用于打印输出的函数,而且还是一个内置函数,通过此函数,我们可以直接将数据做输出操作,比如说:

>>>print("csdn")
csdn

除了 print() 函数之外,Python 还提供了很多内置函数,表 1 中罗列出了 Python 3.x 环境中的所有内置函数。

表 1 Python 3.x内置函数
内置函数
abs() delattr() hash() memoryview() set()
all() dict() help() min() setattr()
any() dir() hex() next() slicea()
ascii() divmod() id() object() sorted()
bin() enumerate() input() oct() staticmethod()
bool() eval() int() open() str()
breakpoint() 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()

需要注意的是,开发者不建议使用以上内置函数的名字作为标识符使用(作为某个变量、函数、类、模板或其他对象的名称),虽然这样做 Python 解释器不会报错,但这会导致同名的内置函数被覆盖,从而无法使用。例如:

>>> print="csdn"   #Python解释器不会报错
>>> print(print)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    print(print)
TypeError: 'str' object is not callable

相关推荐

  1. Python 函数

    2023-12-19 11:22:03       17 阅读
  2. 详解Python函数 !!!

    2023-12-19 11:22:03       34 阅读
  3. python函数 L

    2023-12-19 11:22:03       17 阅读
  4. python函数 O

    2023-12-19 11:22:03       16 阅读
  5. python函数 T

    2023-12-19 11:22:03       18 阅读
  6. python函数 V

    2023-12-19 11:22:03       19 阅读
  7. python函数 V

    2023-12-19 11:22:03       17 阅读
  8. python函数 Z

    2023-12-19 11:22:03       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-19 11:22:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-19 11:22:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-19 11:22:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-19 11:22:03       18 阅读

热门阅读

  1. js 数据类型

    2023-12-19 11:22:03       39 阅读
  2. tensorflow定制模型和训练算法

    2023-12-19 11:22:03       31 阅读
  3. Cookie和会话安全

    2023-12-19 11:22:03       26 阅读
  4. leetCode算法—6. N 字形变换

    2023-12-19 11:22:03       45 阅读
  5. 智能合约为什么是企业数字化转型的新引擎。

    2023-12-19 11:22:03       38 阅读
  6. Linux 系统常用命令总结

    2023-12-19 11:22:03       31 阅读
  7. SQL中 WITH AS 的使用方法

    2023-12-19 11:22:03       40 阅读
  8. ceph更换硬盘

    2023-12-19 11:22:03       41 阅读
  9. Flink源码分析 | 读取HBase配置

    2023-12-19 11:22:03       49 阅读