python 字符串操作
注释解释:
[3,7) : 索引值在3(包含)到7(不包含)的元素
[5,-1] : 索引值在5(包含)到末尾(-1,包含)的元素
1、字符串的索引与切片
s = 'Hello,good morning!'
s = s[1:10:2] #起始位置,结束位置,步长
print(s)
运行结果
el,od
2、倒序
s = 'Hello,good morning!'
s = s[-1::-1]...
原创
2019-05-18 17:41:11 ·
502 阅读 ·
1 评论