Python 封装一个函数,查找文字字符串数字英文下标

学习备忘录 2019-12-10

def abc(str,data):    count = []    numMax = 0    for a in range(len(str)):        if a == 0:            temp = str.find(data, numMax, len(str))        else:            temp = str.find(data, numMax+1, len(str))        if temp != -1:            for i in range(len(data)):                count.append(temp + i)        elif numMax == 0 and count != None:            return -1        if numMax == max(count):            return count        numMax = max(count)# print(abc(input("请输入一个序列为查找基础:"),input("输入查找内容:")))print(abc("abcfgggabjfhgfabc","abc"))

相关推荐