当前位置:首页 > python教程 > python高级

Python3 tuple 函数

python3 tuple 函数

描述

tuple 函数将可迭代系列(如列表)转换为元组。

语法

以下是 tuple 的语法:

tuple( iterable )
参数
  • iterable -- 要转换为元组的可迭代序列。
返回值

返回元组。

实例

以下展示了使用 tuple 的实例:

实例

>>>list1= ['google', 'taobao', 'runoob', 'baidu'] >>> tuple1=tuple(list1) >>> tuple1 ('google', 'taobao', 'runoob', 'baidu')


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!