import collections
print collections.Counter([
'a',
'b',
'a',
'a',
'c',
'b',
'a',
'd'])
print collections.Counter({
'a':
2,
'b':
3,
'c':
4})
print collections.Counter(a=
2,b=
3,c=
3)
c=collections.Counter()
print c
c.update(
"abdahsdkjsa")
print "Sequence ",c
c.update({
'a':
10,
'v':
10})
print c
c.update([
'a',
'a',
'a',
'a',
'a',
'a',
'a',
'a',
'a',
'a'])
print c
c=collections.Counter(
'dshasajfhabs')
print c
for letter
in 'abcdefg':
print '%s : %d' % (letter,c[letter])
c=collections.Counter(
'extremly')
c[
'z']=
0
print c
print c.elements()
print list(c.elements())
c1=collections.Counter([
'a',
'b',
'c',
'a',
'b',
'b',
'b'])
c2=collections.Counter(
'alphabet')
print 'C1:',c1
print 'C2:',c2
print "结合之后的结果是:",c1+c2
print "相减之后的结果是:",c1-c2
print "相与之后的结果是:",c1&c2
print "相或之后的结果是:",c1|c2
转载请注明原文地址: https://ju.6miu.com/read-970985.html