序列 有序数列
str tupe list str tupe 不可变 list 可变序列(str list tuple) 每个元素都会有个序号(0开始计数) 1. 知索引取单个确定类型 [index] 2. 知值取索引 .index 3. 切片 [start: end: step], 负数(-1开始计数)从序列倒数第几个取值,空表示从左到右取到最后 4. 取序列的长度 len 5. 求数列中最大最小 max min 非数字类型转化为ascii码对应的数字进行比较 6. 序列求和 sum 7. 序列拼接 + 8. 序列拷贝次数 * 9. 统计元素 .count 10. 删除 delstr_list = ["hai", "hello", "wei", "here", 1, 2, 3]print(str_list[1])print(str_list.index("hai"))print(str_list[:1])print(str_list[::2])print(len(str_list))print(max(str_list[:4]))print(min(str_list[4:]))print(sum(str_list[4:]))print(str_list + [8, "aliYun"])print(str_list * 2)print(str_list.count("hai"))del str_list[0]print(str_list)
判断单个元素是否在这个序列中
1. 是否在 in 2. 是否不在 not instr_elements = "sjidanntlsnakn "print(" " in str_elements)print("sji" not in str_elements)
序列类分类
1. 容器序列 list tupe deque
2. 扁平序列 str bytes bytearray array.array 3. 可变序列 list deque bytearray array 4. 不可变 str tuple bytes # 数组中放同一类数据