返回对象的长度(元素个数),适用于字符串、列表、元组、字典、集合等。
s
整数
print(len("Python"), len("你好")) print(len([1, 2, 3]), len({"a": 1}), len(range(0, 100, 7)))
6 2 3 1 15