set 和 collections --- python
++++++++++++++ My Code +++++++++++++++
# set
s1 = set ([11,22,33])
s2 = set([33,44,55])
ret = s1.difference(s2)
ret2 = s2.symmetric_difference(s2)
print(ret)
print(ret2)
# collection 计数器
import collections
obj = collections.Counter('123',abc)
print (obj)
reg = obj.most_common(2)
print (reg)
for key in obj.elemets():
print (key)
for k,v in obj.items():
print (k,v)

浙公网安备 33010602011771号