写错了吧,应该是h.keys()
或者直接写h就可以了、
def print_hist(h): d=[] #d += sorted(h) d += sorted(h.keys()) for c in d: print (c, h[c])
应该是d.keys()吧?