求两个字符串最大公共子串
def getCommonStr(str1, str2):
"""求两个字符串最大公共子串"""
rst_str = ''
curr_num, begin_num = 0, 0
i = len(str1)
while i:
curr_num += 1
ex_str = str1[begin_num : curr_num]
if ex_str in str2:
if len(ex_str) > len(rst_str):
rst_str = ex_str
else:
begin_num = curr_num - 1
ex_str = str1[begin_num:curr_num]
if ex_str in str2:
if len(ex_str) > rst_str:
rst_str = ex_str
else:
begin_num = curr_num
i -= 1
return rst_str