标签:[] star col color def app 字符 div 最大
在python中统计两个字符串从首字符开始最大连续相同的字符数,函数如下:
def get_num(s1, s2): num = 0 len_s1 = len(s1) list_s1 = [] for i in range(len_s1): two_s1 = s1[0:i+1] list_s1.append(two_s1) for i in list_s1: if s2.startswith(i) and len(i) > num: num = len(i) return num
标签:[] star col color def app 字符 div 最大
原文地址:https://www.cnblogs.com/lucky-heng/p/9940288.html