标签:循环 title 类型 成员 pytho 存储 方法 tuple 运算
num = (1,2,3,4,5,6)
# num = tuple((1,2,3,4,5,6))
1:按索引取值(正向或反向取),只能取
num = (1,2,3,4,5,6)
print(num[5]) # 6
2:切片(顾头不顾尾,步长)
num = (1,2,3,4,5,6)
print(num[0::2]) # (1, 3, 5)
3:len 长度
num = (1,2,3,4,5,6)
print(len(num)) # 6
4:成员运算 in 和 not in
num = (1,2,3,4,5,6)
print(2 in num) # True
print(2 not in num) # False
5:循环
num = (1,2,3,4,5,6)
for i in num:
print(i)
# 1
# 2
# 3
# 4
# 5
# 6
标签:循环 title 类型 成员 pytho 存储 方法 tuple 运算
原文地址:https://www.cnblogs.com/jincoco/p/11135408.html