python的数据类型---tuple
2021-07-13 04:07
                         标签:元素   python   定义   col   类型   code   使用   通过   nbsp    tuple也是一个sequence,但是同list 以及dict不同之处在于,tuple一旦定义,就无法对其进行修改(增、删、改),只能对tuple进行查询。 通常我们说的查询,无外乎就是这几种的查询: 1、知道元素的小标位置,通过下标进行查询 2、知道元素的内容,直接通过元素内容进行查询 3、查询一定范围的下标的内容 4、确定一个元素是否在tuple中,  in函数 下面请看函数的使用 print(tup1+tup2)  #(‘physics‘, ‘chemistry‘, 1997, 2000, 1, 2, 3, 4, 5, 6, 7)   python的数据类型---tuple 标签:元素   python   定义   col   类型   code   使用   通过   nbsp    原文地址:https://www.cnblogs.com/miyatest/p/9542764.htmltt = (1,) #一个元素的时候,一定要在后面添加逗号
tup1 = (‘physics‘, ‘chemistry‘, 1997, 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )print(tup1[0])  #physics
print(tup2[0:3]) #(1, 2, 3)print(‘physics‘ in tup1)  #True
下一篇:排序算法对比,步骤,改进
文章标题:python的数据类型---tuple
文章链接:http://soscw.com/index.php/essay/104476.html