代码:
def perm(s=''): if len(s) <= 1: return [s] sl = [] for i in range(len(s)): for j in perm(s[0:i] + s[i + 1:]): sl.append(s[i] + j) return sl def main(): perm_nums = perm('seddd') no_repeat_nums = list(set(perm_nums)) # 去重 print('perm_nums', len(perm_nums), perm_nums) print('no_repeat_nums', len(no_repeat_nums), no_repeat_nums) pass if __name__ == '__main__': main()