这是我能提出的最接近的:Convert list of ints to one number?
基本上,我有一个整数列表列表:
arr = [[2,3,4], [1,2,3], [3,4,5]]
我如何得到这个:[234,123,345]整数?
编辑:我想要渲染我可以使用的代码:
result = np.zeros(len(arr))
for i in range(len(arr)):
result[i] = int(''.join(map(str, arr[i])))
答案 0 :(得分:3)
[int(''.join(map(str, x))) for x in arr]
# [234, 123, 345]
答案 1 :(得分:0)
arr = [[2,3,4], [1,2,3], [3,4,5]]
arr2 = []
for x in arr:
z = ""
for y in x:
z = z + str(y)
arr2.append(int(z))
#the results are now in arr2
print arr2
答案 2 :(得分:0)
稍微更加数学化的方式:
>>> [sum(n*10**i for i, n in enumerate(reversed(x))) for x in arr]
[234, 123, 345]