索引取值
name_tuple=('888','hjk','ik')
print(f"name_tuple[2]:{name_tuple[2]}")
name_tuple[2]:ik
切片(顾头不顾尾)
print(name_tuple[1:2:2])
('hjk',)
长度len
print(f"len(name_tuple):{len(name_tuple)}")
len(name_tuple):3
in not in
print('888'in name_tuple)
True
循环for
for i in name_tuple:
print(i)
888
hjk
ik
count计数
print(f"name_tuple.count('ik'):{name_tuple.count('ik')}")
name_tuple.count('ik'):1
index索引
print(f"name_tuple.index('ik'):{name_tuple.index('ik')}")
name_tuple.index('ik'):2
元组索引对应的值的内存地址是不可改变的
标签:index,name,tuple,len,元组,ik,print
From: https://www.cnblogs.com/nickyu511/p/17999631