开班前自学--元组
作者:互联网
元组 tuple
- 元组可以查询
tu = ('front','ove',['library','cloudpark','CC+'],'2019.03.01','09:06') print(tu[-2]) # 2019.03.01 print(tu[:5:2]) # ('front', ['library', 'cloudpark', 'CC+'], '09:06') print(len(tu)) # 5 print(tu.index('ove')) # 1 print(tu.count('2019.03.01')) # 1
- 元组不可编辑,即不能进行增加,更改,删除
- 元组内如有列表,列表可修改
tu = ('front','ove',['library','cloudpark','CC+'],'2019.03.01','09:06') tu[2].append('shenzhen') print(tu) # ('front', 'ove', ['library', 'cloudpark', 'CC+', 'shenzhen'], '2019.03.01', '09:06')
tu = ('front','ove',['library','cloudpark','CC+'],'2019.03.01','09:06') tu[2].pop(2) # 删除'CC+' print(tu) # ('front', 'ove', ['library', 'cloudpark'], '2019.03.01', '09:06')
标签:01,2019.03,tu,library,开班,09,print,自学,元组 来源: https://www.cnblogs.com/yingpeng/p/10455743.html