Python中的len() 方法的作用是返回列表元素个数
#语法
len(list)
def demo():
list1, list2 = [123, "xyz", "zara"], [456, "abc"]
print("First list length : ", len(list1))
print("Second list length : ", len(list2))
输出结果:
First list length : 3
Second list length : 2
Python len() 函数详解
本文介绍了Python内置的len()函数,它用于获取列表、元组、字符串等可迭代对象的元素数量。通过len(),你可以快速得知序列的长度。
3193

被折叠的 条评论
为什么被折叠?



