—super—

博客园 首页 新随笔 联系 订阅 管理

#元组的元素可以是任意数据类型
t=('a',1,'b',1,(3,4))
# print(id(t),type(t),t)

 


#元组的特性是:不可变

#取值
# print(t[4][0])

#循环
t=('a',1,'b',1,(3,4))
# index=0
# while index < len(t):
# print(t[index])
# index+=1

# for i in range(len(t)):
# print(t[i])


#tuple类型的方法
# print(t.count(1))
# print(t.index('b'))


#tuple常用操作
# 索引
# 切片
# t=('a',1,'b',1,(3,4))
# print(t[1:3])
# print(t)
# 循环
# 长度
# print(len(t))
# 包含
#
# print('a' in t)

 

#元组的特性是:不可变,元组的元素可以是任意数据类型
# t=(1,2,['a','b'])
# print(id(t),type(t),t)

# t[2][0]='aaaaaaa'
# print(t)
# print(id(t),type(t),t)

# t[2]=3
# t[2][0]=123123123123

 


#评论

# comments=[('真傻比',),('确实傻逼',)]
# print(comments)
# # comments.pop(0)
# comments[0]='真牛逼'
# print(comments

posted on 2017-07-21 14:03  —super—  阅读(120)  评论(0编辑  收藏  举报