python while - list 遍历列表
# python while - 遍历列表 mylist = ['a','b','c'] mylist2 = [] while mylist: popVal = mylist.pop() mylist2.append(popVal) print(mylist,mylist2) # python 删除包含特定值的所有列表元素 list_a = ['a','b','c','b','d','b','e'] print('删除b前:',list_a) while 'b' in list_a: list_a.remove('b') print('删除b后:',list_a)