格式:users=('fa',11,99,'daf')
注意:元组不可变类型。
功能
- 索引
users=('fa',11,99,'daf')
print(users[0])
fa
- 步长
users=('fa',11,99,'daf')
print(users[0::2])
('fa', 99)
- 切片
users=('fa',11,99,'daf')
print(users[0::])
('fa', 11, 99, 'daf')
- len
users=('fa',11,99,'daf')
print(len(users))
4
- for循环
users=('fa',11,99,'daf')
for item in users:
print(item)
fa
11
99
daf
特殊:元组的元素不可被修改/删除