对单个数组值在Python单号 [英] Make individual array values to single number in Python
本文介绍了对单个数组值在Python单号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个阵列像下面。
a = [1,2,3,4]
我想使这个数组单一值是这样的:
I want to make this array to single value like this:
a = [1234]
我怎么能在Python这样做吗?
How can I do this in Python?
推荐答案
您可以使用加入
来捧场阵列中的所有元素,但你必须将它们转换为字符串第一:
You can use join
to join all element in array, but you have to convert them to a string first:
>>> a = [1,2,3,4]
>>> [int(''.join([str(i) for i in a]))]
[1234]
这篇关于对单个数组值在Python单号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文