题解 | #字符统计#
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
import sys for line in sys.stdin: dic: dict = {} for x in line.strip("\n"): if x not in dic.keys(): dic[x] = 1 else: dic[x] += 1 # print(dic) print("".join(str(x[0]) for x in sorted(dic.items(), key=lambda x: (-x[1], x[0]))))