python算法获取字符串最大前缀
#!encoding=utf8
import re
def func(str_list):
result = []
if len(str_list) == 0:
return result
elif len(str_list) == 1:
result.append(str_list[0])
return result
def prefix(str_list, no):
if no > max([len(i) for i in str_list]):
result.append(str_list[0])
return
tem_list = [i[0:no] for i in str_list]
d = {}
for i in tem_list:
d[i[0:no]] = tem_list.coun
共有 0 条评论