python 遍历列表每次遍历两个元素
问题: 例如: li= [1,2,3,4,5,6,7,8,9,10] 想要输出: [1,2] [3,4] [5,6] [7,8] [9,10]
方案一: 对列表进行拆分: def test1(): onum=[] jnum=[] for i in ewr: if i%2==0: onum.append(i) else: jnum.append(i) for i,j in zip(jnum,onum): print(i,j)
方案二: def test2(): for i in range(4): ret = ewr[0:2] print(ret) for i in ret: ewr.remove(i)
期待更多解决方案!!!