如何去除列表中重复的元素
作者:互联网
li = [100,45,'lisi','wangwu',100,'lisi'] 去除列表中重复的多余元素;
li = [100,45,'lisi','wangwu',100,'lisi'] new_li = [] for i in li: if i not in new_li: new_li.append(i) print(new_li)
/usr/local/bin/python3.6 "/Users/muxiuyulin/Desktop/study python/test4.py"
[100, 45, 'lisi', 'wangwu']
Process finished with exit code 0
标签:重复,45,li,lisi,wangwu,去除,new,100,列表 来源: https://www.cnblogs.com/banzisky/p/14995414.html