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)

 

posted @ 2017-03-16 00:34  BETS&ME  Views(92)  Comments(0)    收藏  举报