#-*-coding:utf-8-*- ''' 字符串索引与切片 ''' # 索引 s = 'bowen' s1 =s[0] # b print(s1) # 切片,包头不包尾 s2 = s[:3] print(s2) # bow s3 = s[-1] print(s3) # n s4 = s[-2] print(s4) # e s5 =s[:] print(s5) # 复制 s6 = s[0:0] print(s6)
Python(28)_字符串的索引和切片
猜你喜欢
转载自www.cnblogs.com/sunnybowen/p/10199316.html
今日推荐
周排行