zoukankan      html  css  js  c++  java
  • Python python对象 enumerate

    """
    enumerate(iterable[, start]) -> iterator for index, value of iterable
    
    Return an enumerate object.  iterable must be another object that supports
    iteration.  The enumerate object yields pairs containing a count (from
    start, which defaults to zero) and a value yielded by the iterable argument.
    enumerate is useful for obtaining an indexed list:
        (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
        """
    seasons = ['Spring', 'Summer', 'Fall', 'Winter'] # The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument.
    var = list(enumerate(seasons))
    print(var) # [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
    
    var =  list(enumerate(seasons, start=1)) # defaults to zero
    print(var) #[(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]
  • 相关阅读:
    go context
    go etcd
    go logs
    go config
    go tail
    kafka与zookeeper
    go kafka
    go mysql
    array_map array_walk
    单独配置的nginx mysql 重启
  • 原文地址:https://www.cnblogs.com/pickKnow/p/10930246.html
Copyright © 2011-2022 走看看