#!/usr/bin/python
# -*- coding: UTF-8 -*-
l = [1,2,3,1,1,1,1,1,1,1,2,2,2,1,1,3]
d = {}
for i in l:
if not d.has_key(i):
d.setdefault(i, l.count(i))
print d
#更简洁的方法,并且速度更快
l = [1,2,3,1,1,1,1,1,1,1,2,2,2,1,1,3]
print dict([(i, l.count(i)) for i in l])