[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
序列类型的元素之间存在先后关系,可以通过索引来访问。当需要访问序列中的某个元素时,只要找出其索引即可。
序列类型支持成员关系操作符( in )、分片运算符([]),序列中的元素也可以是序列类型。
Python 中典型的序列类型包括字符串( str )、列表( list )和元组( tuple )。
由于字符串类型十分常用且单一字符串只能表达一个含义,也被看作是基本的数据类型。
序列的正向索引和反向索引:
序列类型的常用操作符和方法如表所示,其中, s 和 t 是序列, x 是引用序列元素的变量, i 、j 和 k
是序列的索引,这些操作符和方法是学习列表和元组的基础。
序列类型常用操作符:
操作符或方法功能描述
x in s如果 x 是 s 的元素,返回 True ,否则返回 False
s not in s如果 x 不是 s 的元素,返回 True ,否则返回 False
s + t返回 s 和 t 的连接
s * n将序列 s 复制 n 次
s [ i ]索引,返回序列 s 的第 i 项元素
s [ i : j ]分片,返回包含序列 s 第 i 到第 j 项元素的子序列(不包含第 j 项元素)
s [ i : j : k ]返回包含序列 s 第 i 到第 j 项元素中以 k 为步长的子序列
len ( s )返回序列 s 的元素个数(长度)
min ( s )返回序列 s 中的最小元素
max ( s )返回序列 s 中的最大元素
s.index ( x [ , i [ , j ] ] )返回序列 s 中第 i 到第 j 项元素中第一次出现元素 x 的位置
s.count ( x )返回序列 s 中出现 x 的总次数