1. Just enter some strings.
list2 = []
def replace_str(str_len):
for i in range(len(str_len)):
temp = str_len[i]
for j in range(i+1, len(str_len)):
if str_len[j] not in temp:
temp += str_len[j]
else:
break
list2.append(temp)
list2.sort(lambda x, y :cmp(len(x), len(
y)))
return list2[-1]
def mian():
str = input('请输入字符串')
data = replace_str(str)
return data
注释: cmp函数,在python3中已经取消了