字符串的索引和切片

索引: msg='hello world' 正向取 a=msg[1] 反向取 b=msg[-1] ps:只能取不能改

切片: msg='hello world' res=msg[0:5](hello) 切片的步长: res=msg[0:5:2](hlo) 反向步长: res=msg5:0:-1

ps:成员运算也可以用在字符串中

猜你喜欢

转载自www.cnblogs.com/bailongcaptain/p/12458037.html