1. len

    返回列表中元素的个数,同样适用于元组、字典、集合、字符串

    1. def len(*args, **kwargs): # real signature unknown
    2. """ Return the number of items in a container. """
    3. pass
    1. >>> _str = "1234567890"
    2. >>> len(_str)
    3. 10
    4. >>> _tuple = tuple(_str)
    5. >>> len(_tuple)
    6. 10
    7. >>> _list = list(_str)
    8. >>> len(_list)
    9. 10
    1. zip

    返回多个可遍历变量组合后的元组列表

    1. class zip(object):
    2. """
    3. zip(iter1 [,iter2 [...]]) --> zip object
    4. Return a zip object whose .__next__() method returns a tuple where
    5. the i-th element comes from the i-th iterable argument. The .__next__()
    6. method continues until the shortest iterable in the argument sequence
    7. is exhausted and then it raises StopIteration.
    1. >>> s1 = "12345"
    2. >>> s2 = "67890"
    3. >>> for i, j in zip(s1, s2):
    4. ... print(i, j)
    5. ...
    6. 1 6
    7. 2 7
    8. 3 8
    9. 4 9
    10. 5 0
    1. enumerate

    用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中

    1. class enumerate(object):
    2. """
    3. Return an enumerate object.
    4. iterable
    5. an object supporting iteration
    6. The enumerate object yields pairs containing a count (from start, which
    7. defaults to zero) and a value yielded by the iterable argument.
    8. enumerate is useful for obtaining an indexed list:
    9. (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
    10. """
    1. >>> _str = "1234567890"
    2. >>> for i, e in enumerate(_str):
    3. ... print(i, e)
    4. ...
    5. 0 1
    6. 1 2
    7. 2 3
    8. 3 4
    9. 4 5
    10. 5 6
    11. 6 7
    12. 7 8
    13. 8 9
    14. 9 0

    引用:
    [1]. https://blog.csdn.net/eacxzm/article/details/79778769
    [2]. https://www.cnblogs.com/wzwpython/p/11549239.html