题解 | #字符统计#
字符统计
http://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
while True: try: input_string = input() sorted_list = sorted(input_string) dict, ans = {}, '' for item in sorted_list: if item not in dict: number = sorted_list.count(item) dict.setdefault(item, number) new_list = sorted(dict.items(), key=lambda items:(-items[1], items[0])) for item in new_list: ans += item[0] print(ans) except: break