在遍历list的时候,删除符合条件的数据,结果不符合预期 num_list = [1, 2, 2, 2, 3] print(num_list) for item in num_list: if item == 2: num_list.remove(item) else: print(item) print(num_list) 结果是 [1, 2, 2, 2, 3] 1 [1, 2, 3] 或者有: num_list = [1, 2, 3, 4, 5] print(num_list) for i…