def palindromic_string(s):
result = ''
for i in range(len(s)):
for j in range(i+1,len(s)):
value = s[i:j+1:]
_value = "".join(reversed(value))
if value == _value and len(value) > len(result):
result = value
return result if result != '' else '该字符串不含回文串'
s = 'aabasij'
print(palindromic_string(s))
编写函数,参数为一个字符串,返回这个字符串所有子串里面构成回文串的最大子串
最新推荐文章于 2024-03-08 16:39:10 发布