标签: python
如何列出以下列表:
data = ['a','b','c','d','e','f','g','h','i']
到
data = [['a','b','c'],['d','e','f'],['g','h','i']]
答案 0 :(得分:1)
[a[i:i+3] for i in range(0, len(a), 3)]