python tuple什么意思
python tuple什么意思?
python tuple即元组,tuple()函数将列表转换为元组。
tuple()方法语法:
tuple( seq )
参数
seq -- 要转换为元组的序列。
返回值
返回元组。
以下实例展示了 tuple()函数的使用方法:
实例 1
>>>tuple([1,2,3,4]) (1, 2, 3, 4) >>> tuple({1:2,3:4}) #针对字典 会返回字典的key组成的tuple (1, 3) >>> tuple((1,2,3,4)) #元组会返回元组自身 (1, 2, 3, 4)
实例 2
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc']; aTuple = tuple(aList) print "Tuple elements : ", aTuple
以上实例输出结果为:
Tuple elements : (123, 'xyz', 'zara', 'abc')
相关推荐:《Python教程》
以上就是python tuple什么意思的详细内容,更多请关注教程集其它相关文章!
您可能感兴趣的文章:
python tuple什么意思
python中的tuple是什么
python list和tuple的区别
python中tuple指什么
Python有什么数据结构
怎么用python中tuple相关方法?
python tuple怎么用
python中的%是什么意思
python中tuple相关方法如何使用?
Python正则表达式findall函数详解