day3—python——元组
t = ('abc',) #只有一个元素时也要加逗号
mysql = ('118.24.3.40',3306,'root','123456')
#元组也是一个不可变列表,元组不能修改
print(mysql[:3])
#打印:
('118.24.3.40', 3306, 'root')
for m in mysql:
print(m)
#元组也可以循环
#打印:
118.24.3.40
3306
root
123456
mysql.count() #用于统计某个元素在元祖中出现的次数
mysql.index() #用于计算某个元素在元祖中的下标
l = [1]
t = ('abc',)
print(type(t))
print(type(l))
#判断类型

浙公网安备 33010602011771号