本文实例讲述了Python实现连接两个无规则列表后删除重复元素并升序排序的方法。分享给大家供大家参考,具体如下:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 | # -*- coding:utf-8 -*- #! python2 list_one Stream Vera Sans Mono', 'Courier New', Courier, monospace !important; float: none !important; border-top-width: 0px !important; border-bottom-width: 0px !important; height: auto !important; color: rgb(0, 102, 153) !important; vertical-align: baseline !important; overflow: visible !important; top: auto !important; right: auto !important; font-weight: bold !important; left: auto !important; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;" class="py keyword">= [ 3 , 6 , 2 , 17 , 7 , 33 , 11 , 7 ] list_two = [ 1 , 2 , 3 , 7 , 4 , 2 , 17 , 33 , 11 ] list_new = list_one + list_two list = [] i = 0 for x in list_new : if x not in list : list .append(x) list .sort() print list |
运行结果: