温馨提示×

python使用tuple函数将列表转换为元组

养鱼的猫咪
1417
2021-03-16 08:21:15
栏目: 编程语言
Python开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python使用tuple函数将列表转换为元组

在python中使用tuple()函数将列表转换为元组的方法

tuple:tuple()函数的作用是将列表转换为元组。

tuple()函数语法:

tuple( iterable )

参数:

iterable:表示需要转换为元组的可迭代序列。

tuple()函数使用方法:

List = [123, 'xyz', 'zara', 'abc'];

aTuple = tuple(List)

print "Tuple elements : ", aTuple

输出结果为:

Tuple elements : (123, 'xyz', 'zara', 'abc')

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:python使用hex函数将10进制转换为16进制

0