list1 = ['1', '2', '3', '4'] list2 = ['1', '2', '5', '6']
求取差集:
['3', '4', '5', '6']
阿神2017-04-17 11:12:12
list1 = ['1', '2','3','4'] list2 = ['1', '2', '5', '6'] set1 = set(list2) - set(list1) set2 = set(list1) - set(list2) newlist = list(set1)+list(set2) print sorted(newlist)
应该还有更简洁的方法.