55问答网
所有问题
python里怎么tuple转list
如题所述
举报该问题
推荐答案 2016-07-12
Python中,tuple和list均为内置类型,
以list作为参数将tuple类初始化,将返回tuple类型
tuple([1,2,3]) #list转换为tuple
以tuple作为参数将list类初始化,将返回list类型
list((1,2,3)) #tuple转换为list
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://55.wendadaohang.com/zd/8Q4LIeLI8GLQLRQG8Q.html
相似回答
python里怎么tuple转list
答:
tuple([1,2,3]) #
list转换为tuple
以tuple作为参数将list类初始化,将返回list类型 list((1,2,3)) #
tuple转换为list
Python
3
list
、
tuple
、str之间的相互
转换
答:
1.
list
()方法是把str或
元组转换
成列表 2.tuple()方法是把str或列表转换成元组 3. join函数是把列表和元组转换成str >>> " ".join(tuple(a)) 'abcde' >>> " ".join(list(a)) ‘abcde’ >>> str(tuple(a)) "('a','b','c','d','e')"
python
类型
转换
答:
complex(real [,imag ]) 创建一个复数;str(x ) 将对象 x
转换为
字符串;repr(x ) 将对象 x 转换为表达式字符串;eval(str ) 用来计算在字符串
中的
有效
Python
表达式,并返回一个对象;
tuple
(s ) 将序列 s 转换为一个元组;
list
(s ) 将序列 s 转换为一个列表;chr(x ) 将一个整数转...
Python 中的
列表
List
是可以改变的, 元组
Tuple
是不可以改变的, 那...
答:
Tuple 可以转换成 list,反之亦然
。内置的 tuple 函数接收一个 list,并返回一个有着相同元素的 tuple。而 list 函数接收一个 tuple 返回一个 list。从效果上看,tuple 冻结一个 list,而 list 解冻一个 tuple。Tuple 的其他应用 一次赋多值 >>> v = ('a', 'b', 'e')>>> (x, y, z...
急求
python的
一个题!s1=[0,1,2,3,4,5,6] s2=['SUN','MON','TUE','WED...
答:
示例:In [1]: a=[1,2,3,4,5,6,7,8]In [2]: b=(1,2,3,4,5,6,7,8)In [3]: a[0::2]Out[3]: [1, 3, 5, 7]In [4]: b[0::2]Out[4]: (1, 3, 5, 7)In [5]:
大家正在搜
python set转list
python list转str
python把str转成list
python int转str
python str转json
python 字符串转list
tuple python
python ctypes
python tuple函数
相关问题
Python里面如何实现tuple和list的转换
python 中怎样把很多的list存放到tuple元祖中?
Python tuple, list 和 string的转换...
Python 中的列表 List 是可以改变的, 元组 Tu...
python中的list中多个有包含tuple的list,如...
Python tuple怎么转成字符串
Python的tuple与list有什么不同,各有什么作用?
python List里可以包含tuple?tuple里可以...