「Python」unionで重複がない要素の和集合を求める方法
pythonコード
# coding: utf-8
cftA = {“apple","pear","CC"}
cftB = {“AA","BB","CC"}
cftC = cftA.union(cftB)
print(cftC)
print(cftA|cftB)
运行结果
{'pear’, 'apple’, 'AA’, 'CC’, 'BB’}
{'pear’, 'apple’, 'AA’, 'CC’, 'BB’}
Coding Changes the World
pythonコード
# coding: utf-8
cftA = {“apple","pear","CC"}
cftB = {“AA","BB","CC"}
cftC = cftA.union(cftB)
print(cftC)
print(cftA|cftB)
运行结果
{'pear’, 'apple’, 'AA’, 'CC’, 'BB’}
{'pear’, 'apple’, 'AA’, 'CC’, 'BB’}