Python函数 - tuple()

tuple(seq)

描述:

把序列转换成元组

tuple()返回的是一个空的元组

tuple(iterable)

模块:

内建函数

参数:

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)

posted @ 2011-06-30 00:36  LemonLi  阅读(1415)  评论(0编辑  收藏  举报