So when I print the Counter (from collections import Counter) to a file I always get this the literal Counter ({\'Foo\': 12})
from collections import Counter
Counter ({\'Foo\': 12})
Is there anyw
What about explicitly formatting it into the form that you want?
>>> import collections >>> data = [1, 2, 3, 3, 2, 1, 1, 1, 10, 0] >>> c = collections.Counter(data) >>> '{' + ','.join("'{}':{}".format(k, v) for k, v in c.iteritems()) + '}' "{'0':1,'1':4,'2':2,'3':2,'10':1}"