如何去除列表中重复的元素

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

上一篇:php集成开发环境的安装以及Zend Studio开发工具的安装


下一篇:ES6数组去重