最小值=["1"、"2"、"、" 3 "、" 4 "、" 5 "、"、"6"]
给定上面的列表,我如何拆分列表并在每次发现""(仅空引号)时创建另一个列表?
lst =["1","2","","3","4","5","","6"]
lst2 = []
for a in lst:
if a == "":
continue
lst2.append(int(a))
print(lst2)
Output:[1, 2, 3, 4, 5, 6]
预期产出:第二次登录=[["1"、"2"]、["3"、"4"、"5"]、["6"]]
1条答案
按热度按时间y53ybaqx1#