code
#coding=utf-8 def getdic(s): dic = {} for i in s: if (i not in dic): dic[i] = 1 else: dic[i] += 1 return dic s1="csddc" s2="cdcsdsdwegtghyhjk" dics1=getdic(s1) length=len(s1) flag=False for i in range(len(s2)): if(s2[i] in s1): if(getdic(s2[i:i+length])==dics1): flag=True break if(flag): print("Founded!") else: print("No founded!")
输出
Founded!