13 元组 公共功能(独有功能无)
元组书写规范
users = [11,22,33,"老男孩"] # 列表(可变)
users = (11,22,33,"老男孩") # 元组(不可变)
公共功能
1、索引
(排除:int / bool )
users = (11,22,33,"老男孩")
print(users[0])
print(users[-1])
2、切片
(排除:int / bool)
users = (11,22,33,"老男孩")
print(users[0:2])
3、步长
(排除:int / bool)
users = (11,22,33,"老男孩")
print(users[0:2:2])
4、删除(无)
(排除:tuple / str / int / bool)
5、修改(无)
(排除:tuple / str / int / bool)
6、for循环
users = (11,22,33,"老男孩")
for item in users:
print(item)
7、len
(排除:int/bool)
users = (11,22,33,"老男孩")
print(len(users))