Manual
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
直译
返回对象s的长度(或项数)。该参数可以是序列(例如字符串、字节、元组、列表或区间)或集合(例如字典、集或冻结集)。
实例
>>> a = '优快云'
>>> len(a)
4
>>> b = bytes('优快云', 'utf-8')
>>> len(b)
4
>>> import os, sys
>>> c = (sys, os)
>>> len(c)
2
>>> d = ['H', 'e', 'l', 'l', 'o']
>>> len(d)
5
>>> e = set(d)
>>> len(e)
4
>>> f = frozenset(d)
>>> len(f)
4
>>> g = {'Friday': 0, 'Wednesday': 0, 'Monday': 0, 'Sunday': 0, 'Tuesday': 0, 'Saturday': 0, 'Thursday': 0}
>>> len(g)
7