📅  最后修改于: 2023-12-03 14:43:52.431000             🧑  作者: Mango
len
function in Pythonlen
is a built-in function in Python that returns the length of an object. The object can be a string, list, tuple, dictionary or any other iterable.
len(object)
The object
parameter is the object for which we want to find the length.
text = "Python is awesome"
print(len(text)) # Output: 17
numbers = [1, 2, 3, 4, 5]
print(len(numbers)) # Output: 5
ages = {"John": 25, "Jane": 30, "Sam": 21}
print(len(ages)) # Output: 3
The len
function is a useful tool for finding the length of an object in Python, whether it's a string, list, tuple, dictionary or any other iterable.