我已经编写了这段代码,它打印给定字符串的所有子字符串,但我希望它打印所有可能的子序列。
from itertools import combinations_with_replacement
s = 'MISSISSIPPI'
lst = []
for i,j in combinations_with_replacement(range(len(s)), 2):
print(s[i:(j+1)])
Run Code Online (Sandbox Code Playgroud)