📜  查找特定长度的字符串的所有唯一子字符串排列python代码示例

📅  最后修改于: 2022-03-11 14:45:54.403000             🧑  作者: Mango

代码示例1
import itertools

x = "some string"

# aList contains all permutations of all lengths of string x
aList = [each for eachpermut in [''.join(l) for i in range(len(x)) for l in itertools.combinations(x, i+1)] for each in [''.join(eachpermut) for eachpermut in list(itertools.permutations(eachpermut))]]

# aSet only contains unique permutations of aList of varying lengths
aSet = set(aList))