题解 | #字符统计# 字典多重排序
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
s=input() s1=set(s) #print(s1) res={} for i in s1: n=s.count(i) res[i]=n res1=sorted(res.items(),key=lambda x:(x[1],-ord(x[0])),reverse=True) #print(res1) print(''.join([i[0] for i in res1]))
字典多重排序:res1=sorted(res.items(),key=lambda x:(x[1],-ord(x[0])),reverse=True) 输出结果为列表