标签:color dff set int pre pytho bsp 方法 eww
#取出字符串中出现2次的字符串,使用count方法统计
def two_zifuchuan(str): s=set() for i in str: if str.count(i)==2: s.add(i) return s #取出字符串中出现2次的字符串,使用字典统计 def two_occur(str): s={} for i in str: if i in s.keys(): s[i]+=1 else: s[i]=1 return [i for i in s if s[i]==2] str="dddredddddewws22dff43" print(two_zifuchuan(str)) print(two_occur(str))
标签:color dff set int pre pytho bsp 方法 eww
原文地址:https://www.cnblogs.com/xiaokuangnvhai/p/11465194.html