int数组转化为数值的python函数?
答案:3 悬赏:30 手机版
解决时间 2021-03-31 00:16
- 提问者网友:雾里闻花香
- 2021-03-30 08:09
int数组转化为数值的python函数?
最佳答案
- 五星知识达人网友:千夜
- 2021-03-30 09:10
''.join(
map(str, intserial)
)''.join( # 将后面的字符串列表用 '' 拼接起来;
map(str, intserial) # 将intserial中的每个变量用str函数转换成字符串的列表
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> intserial=range(15)
>>> intserial
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> ''.join(
... map(str, intserial)
... )
'01234567891011121314'
>>>
map(str, intserial)
)''.join( # 将后面的字符串列表用 '' 拼接起来;
map(str, intserial) # 将intserial中的每个变量用str函数转换成字符串的列表
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> intserial=range(15)
>>> intserial
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> ''.join(
... map(str, intserial)
... )
'01234567891011121314'
>>>
全部回答
- 1楼网友:怀裏藏嬌
- 2021-03-30 09:57
很简单,主要工作就是在 def convert(int_tuple): 方法里面
def convert(int_tuple):
total_number = '';
for i in range(0,len(int_tuple)):
total_number += str(int_tuple[i])
return int(total_number)
def main():
a = [1,2,4,5,60,7,8]
result = convert(a)
print result
print type(result)
if __name__ == "__main__":
main()
def convert(int_tuple):
total_number = '';
for i in range(0,len(int_tuple)):
total_number += str(int_tuple[i])
return int(total_number)
def main():
a = [1,2,4,5,60,7,8]
result = convert(a)
print result
print type(result)
if __name__ == "__main__":
main()
- 2楼网友:话散在刀尖上
- 2021-03-30 09:29
这个简单
>>> import string
>>> a=[1, 2, 3, 33, 66, 2]
>>> print string.join([str(c) for c in a],'')
结果
12333662
>>> import string
>>> a=[1, 2, 3, 33, 66, 2]
>>> print string.join([str(c) for c in a],'')
结果
12333662
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
正方形一边上任一点到这个正方形两条对角线的 |
阴历怎么看 ? |