同列表一样,不做详细测试 https://blog.csdn.net/weixin_41736752/article/details/96437875
不能改元组,但是可以改元组中的列表
tp=('a','b','c',['a','b','c']) tp[3][1]='nice' #('a', 'b', 'c', ['a', 'nice', 'c'])最大值最小值
max(tp) min(tp)
tp=(1,5,9,4,5,10) print(max(tp),min(tp)) #10 1元素遍历
tp=('one','two','and','a','b') for i in tp: print(i,end=' ')索引遍历
tp=('one','two','and','a','b') for i in range(len(tp)): print(tp[i],end=' ')枚举enumerate
tp=('one','two','and','a','b') for i in enumerate(tp,1): print(i,end=' ') #(1, 'one') (2, 'two') (3, 'and') (4, 'a') (5, 'b')字符串、列表、元组的相同点和不同点
符号引号“ ”方括号[ ]小括号()特征字符串列表元组类型stringlisttuple顺序\有序有序重复、索引、切片TTT增Tappend()、extend()、insert(位置,元素)F删s.strip(“指定字符”)pop()、remove()、del、clear()del改s.replace([现有],[替新],替换数量)TF查s.find()、s.index()、s.rindex()、Tindex()特点简单易操作拷贝注意三种情况不能对创建好的元组操作