集合操作
附上代码:
1 M = int(input())
2 m = set(map(int, raw_input().strip().split()))
3 N = int(input())
4 n = set(map(int, raw_input().strip().split()))
5 tmp = sorted(m.union(n).difference(m.intersection(n)))
6 for i in xrange(len(tmp)):
7 print tmp[i]
本文介绍了一种使用Python进行集合操作的方法,并提供了一个具体的代码示例。该示例通过输入两个集合,然后求出这两个集合的并集与交集的差集,并按顺序输出结果。
297

被折叠的 条评论
为什么被折叠?



