【python小随笔】将一个列表的值,分成10个一组,遍历的时候每10个遍历一次

t = [‘B071LF9R6G‘, ‘B0714BP3H4‘, ‘B0756FL8R7‘, ‘B072HX95ZR‘, ‘B07CX389LX‘, ‘B07D9MZ7BD‘, ‘B07D9L15L5‘, ‘B00L1UNPZ0‘,
      ‘B07KDL9RSD‘, ‘B01N02WUM3‘, ‘B072KTNZMW‘, ‘B071Z71BXW‘, ‘B00DU76BOY‘, ‘B07D9NC33M‘, ‘B07G82D89J‘, ‘B076C9X4KS‘,
      ‘B07CTMG6Y9‘, ‘B071JZ78TD‘, ‘B01NBPP89Y‘, ‘B000LJ60F4‘, ‘B07FBJ8CT1‘, ‘B01N77XY1C‘, ‘B06XSCR62Y‘, ‘B078H4FK45‘,
      ‘B01MRVTY7K‘, ‘B07HKH4XMT‘, ‘B0711R3WFH‘, ‘B0725QD6JX‘, ‘B01NCKJSV6‘, ‘2222222222‘, ‘B07HJYHH95‘, ‘B0030MIIOU‘,
      ‘B07HGD4R5N‘, ‘B07PKXNGZH‘, ‘B01HIS1IXE‘, ‘B06XKLFMMV‘, ‘B01DB4TEX0‘, ‘B07B41S34Q‘, ‘B07BL2HT3R‘, ‘B07B712499‘,
      ‘B0716PK6R2‘, ‘B077X9J24C‘, ‘B01N2SBH4J‘, ‘B072854G8H‘, ‘B07KTD2YQ1‘, ‘B07BL3469H‘, ‘B07TJQ5DZN‘, ‘B0711TJZ99‘]


step = 10
b = [t[i:i+step] for i in range(0,len(t),step)]

for x in b:
    print(x)遍历结果为10个一组 10个一组的遍历

[‘B071LF9R6G‘, ‘B0714BP3H4‘, ‘B0756FL8R7‘, ‘B072HX95ZR‘, ‘B07CX389LX‘, ‘B07D9MZ7BD‘, ‘B07D9L15L5‘, ‘B00L1UNPZ0‘, ‘B07KDL9RSD‘, ‘B01N02WUM3‘]
[‘B072KTNZMW‘, ‘B071Z71BXW‘, ‘B00DU76BOY‘, ‘B07D9NC33M‘, ‘B07G82D89J‘, ‘B076C9X4KS‘, ‘B07CTMG6Y9‘, ‘B071JZ78TD‘, ‘B01NBPP89Y‘, ‘B000LJ60F4‘]
[‘B07FBJ8CT1‘, ‘B01N77XY1C‘, ‘B06XSCR62Y‘, ‘B078H4FK45‘, ‘B01MRVTY7K‘, ‘B07HKH4XMT‘, ‘B0711R3WFH‘, ‘B0725QD6JX‘, ‘B01NCKJSV6‘, ‘2222222222‘]
[‘B07HJYHH95‘, ‘B0030MIIOU‘, ‘B07HGD4R5N‘, ‘B07PKXNGZH‘, ‘B01HIS1IXE‘, ‘B06XKLFMMV‘, ‘B01DB4TEX0‘, ‘B07B41S34Q‘, ‘B07BL2HT3R‘, ‘B07B712499‘]
[‘B0716PK6R2‘, ‘B077X9J24C‘, ‘B01N2SBH4J‘, ‘B072854G8H‘, ‘B07KTD2YQ1‘, ‘B07BL3469H‘, ‘B07TJQ5DZN‘, ‘B0711TJZ99‘]