Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 built-in function

Python3 built-in function

Python provides a large number ofbuilt-in functionsthat can be used directly without importing any library. These functions coverdata type conversion, mathematical computation, iteration, and reflectionand other common scenarios; they are essential tools every Python beginner must master.

Why master the built-in functions?

Common categories

Examples of common functions

# 求和
sum([1, 2, 3])  # 6

# 最大值
max([3, 6, 2])  # 6

# Type casting
int("123")      # 123

# 枚举
for i, v in enumerate(['a', 'b']):
    print(i, v)

# map
list(map(lambda x: x * 2, [1,2,3]))  # [2,4,6]

Function quick reference table

Built-in functions
abs()
all()
any()
ascii()
bin()
bool()
bytearray()
bytes()
callable()
chr()
classmethod()
compile()
complex()
delattr()