Python 如何将元组的元素连接在一起并转换为数字
我需要加入tup1的元素,使其成为一个数字。 每个置换数必须转换为数字Python 如何将元组的元素连接在一起并转换为数字,python,Python,我需要加入tup1的元素,使其成为一个数字。 每个置换数必须转换为数字 from itertools import permutations a,b= input().split() a = int(a) b = int(b) default = -1 c = [int(i) for i in str(a)] perm = permutations(c) for tupl in list(perm): res = list(map("".join, tupl)) #num =
from itertools import permutations
a,b= input().split()
a = int(a)
b = int(b)
default = -1
c = [int(i) for i in str(a)]
perm = permutations(c)
for tupl in list(perm):
res = list(map("".join, tupl))
#num = ''.join(j) for j in tupl
print("\n")
# print( num)
# for j in range(0,len(tupl)):
# print(tupl[j])
# res = [''.join(tups) for tups in ]
还是作为一个班轮
>>> a = 213
>>> for tupl in permutations(str(a)):
... num = int(''.join(tupl))
... print (num)
...
213
231
123
132
321
312
还是作为一个班轮
>>> a = 213
>>> for tupl in permutations(str(a)):
... num = int(''.join(tupl))
... print (num)
...
213
231
123
132
321
312