知行编程网知行编程网  2022-11-25 07:00 知行编程网 隐藏边栏  1 
文章评分 0 次,平均分 0.0
导语: 本文主要介绍了关于Python内置函数一览表的相关知识,包括isinstance函数,以及基本的python内置函数这些编程知识,希望对大家有参考作用。

Python 内置函数列表

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

比如print在Python 2.x中只是一个关键字,但是在Python 3.x中print是一个打印输出的函数,也是一个内置函数。通过这个函数,我们可以直接输出数据进行操作,比如:

>>>print("php中文网")
php中文网

除了 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="php中文网"   #Python解释器不会报错
>>> print(print)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    print(print)
TypeError: 'str' object is not callable

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

知行编程网
知行编程网 关注:1    粉丝:1
这个人很懒,什么都没写
扫一扫二维码分享