我试图每隔 5 个项目拆分一个列表,然后删除接下来的两个项目('nan')。我曾尝试使用 List[:5],但这似乎无法循环使用。所需的输出是:[['1','2','3','4','5'],['1','2','3','4','5'], ['1','2','3','4','5'],['1','2','3','4','5']]
List = ['1','2','3','4','5','nan','nan','1','2','3','4','5','nan','nan','1','2','3','4','5','nan','nan','1','2','3','4','5','nan','nan']
for i in List:
# split first 5 items
# delete next two items
# Desired output:
# [['1','2','3','4','5'],['1','2','3','4','5'],['1','2','3','4','5'],['1','2','3','4','5']]
侃侃尔雅
白衣非少年
森栏
qq_花开花谢_0
相关分类