def func(): ''' 把字符串当中重复的字符打印出来 :return: ''' str1 = 'acbdac' for i in set(str1): if str1.count(i) > 1: print(i) func() 运行结果: a c