给定数字的可能排列

问题描述 投票:0回答:1

这是找出给定数字可能排列的代码...,是否有可能减少代码

from itertools import permutations
lst=[int(x) for x in input()] #taking input and split
perm = list(permutations(lst))
for i in range(0,len(perm)):
    perm[i]=int("".join(map(str,perm[i])))#join them and covert to int
print(perm)
python-3.x list list-comprehension permutation
1个回答
0
投票
import random
s = input()
perm = int(''.join(random.sample(s,len(s))))
© www.soinside.com 2019 - 2024. All rights reserved.