# coding:utf-8
print("—————————— 序列 ——————————")
# 序列:一个用来存储多个值的连续空间,每个值都对应一个整数的编号,称为索引
# 索引:正向递增索引、反向递减索引
'''
有序序列:列表和元组
无序序列:集合和字典
被称为组合数据类型
'''
print("—————————— 正向递增索引 ————————————")
s = 'helloworld'
for i in range(0,len(s)):print(i,s[i],end='\t\t')
print()print("—————————— 正向递增索引 ————————————")
for i in range(-10,0):print(i,s[i],end='\t\t')
print()print("—————————— 索引的切片 ————————————")
'''
切片的语法结构:序列[star:end:step]
star:切片的开始索引,包含
end:切片的结束索引,不包含
step:步长,默认为1
'''a = 'yours!!'
b = a[0:5:2]
print(b)
print(a[:5:1]) # star省略,默认从0开始
print(a[2::2]) # end省略,默认到序列的最后一个元素,包含最后一个元素
print(a[1:6:]) # step省略,默认为1
print(a[::])
print(a[:])c = 'helloworld'
# in
print("e在helloworld中存在吗?",("e" in c))
# not in
print("e在helloworld中不存在吗?",("e" not in c))
# 内置函数
# len(),长度
print(len(c))
# max(),最大值
print(max(c))
# min(),最小值
print(min(c))# 序列对象的方法,使用序列的方法,打点调用
print(c.index("e")) # e在c中第一次出现的索引位置
print(c.count("e")) # e在c中出现的次数
