python_ extracted strings to appear twice

# Extracted strings to occur twice, using statistical count 
DEF
two_zifuchuan (STR): S = SET () for I in STR: IF str.count (I) == 2 : s.add (I) return S # extracted strings to occur twice, using statistical dictionary DEF two_occur (STR): S = {} for I in STR: IF I in s.keys (): S [I] +. 1 = the else : S [I] =. 1 return [I for I in s if s[i]==2] str="dddredddddewws22dff43" print(two_zifuchuan(str)) print(two_occur(str))

 

Guess you like

Origin www.cnblogs.com/xiaokuangnvhai/p/11465194.html