标签:size pre 1.5 元组 oba lis 语法 pytho tao
Python 元组 tuple() 函数将列表转换为元组。
语法
以下是 tuple 的语法:
tuple( seq )
返回元组。
以下展示了使用 tuple 的实例:
>>>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)
>>>list1= [‘Google‘, ‘Taobao‘, ‘Runoob‘, ‘Baidu‘] >>> tuple1=tuple(list1) >>> tuple1 (‘Google‘, ‘Taobao‘, ‘Runoob‘, ‘Baidu‘)
标签:size pre 1.5 元组 oba lis 语法 pytho tao
原文地址:http://www.cnblogs.com/wushuaishuai/p/7678150.html