题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
http://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
import sys while True: try: s = input() dic = {} for c in s: dic[c] = s.count(c) #按次数排序 ss = sorted(s, key = lambda x: dic[x]) min_count = dic[ss[0]] #把等于最小次数的字符删掉 for c in ss: if dic[c] == min_count: s = s.replace(c, '') else: break print(s) except: # print(sys.exc_info()) break