while True: try: s = input() result = {} for i in s: if i not in result: result[i] = s.count(i) output_list = sorted(result.items(), key = lambda d :(-d[1],d[0]))#这个排序的写法需要背诵,背诵起来。。。 #Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。 #d = {'one': 1, 'two': 2, 'three': 3} #>>> d.items() ...