美文网首页
Python -- 元组Tuple

Python -- 元组Tuple

作者: 墨凌风起 | 来源:发表于2020-05-09 20:54 被阅读0次

'''
元组 Tuple
1.不能二次赋值,只读
2.() 表示,内部元素逗号分隔
'''

创建

tupl1 = ('Google','Runloop',123,24334)
tupl2 = (1,2,3,4,5)
tupl3 = 'a','b','g','h' #不要括号也行
tupl4 = () #创建空元组

**元组只有一个元素,需要在元素后加逗号,否则括号会被当作运算符

tupl5 = (49)
print(type(tupl5)) #<class 'int'>

len(tuple) 元组的个数

max(tuple) 返回元组最大值

min(tuple) 返回元组最小值

tuple(iterable) 将可迭代系列转换为元组

print(tuple(["Java","IOS","C++"]))

in 元素是否存在

+ 元组拼接

* 元组复制

'''

相关文章

网友评论

      本文标题:Python -- 元组Tuple

      本文链接:https://www.haomeiwen.com/subject/wbblnhtx.html