python3 第二十九章 - 内置函数之tuple相关

Python元组包含了以下内置函数

序号方法及描述实例
1 len(tuple)
计算元组元素个数。
>>> tuple1 = ('Google', 'Baidu', 'Taobao')
>>> len(tuple1)
3
>>>
2 max(tuple)
返回元组中元素最大值。
>>> tuple2 = ('5', '4', '8')
>>> max(tuple2)
'8'
>>>
3 min(tuple)
返回元组中元素最小值。
>>> tuple2 = ('5', '4', '8')
>>> min(tuple2)
'4'
>>>
4 tuple(seq)
将列表转换为元组。
>>> list1= ['Google', 'Taobao', 'Baidu']
>>> tuple1=tuple(list1)
>>> tuple1
('Google', 'Taobao', 'Baidu')
posted @ 2018-02-11 16:30  MrBug  阅读(144)  评论(0编辑  收藏  举报

人生就是一场战斗,唯有披荆斩棘,勇往直前!