python 中[:-1]和[::-1]的使用
摘要:a="1234567" b=a[::-1] #7654321 c=a[::-2] #7531 d=a[:-1] #123456 e=a[:-2] #12345 print(b,c,d,e) a[:-1]:格式是a[i:j],也就是a[i]到a[j]之前的内容。i缺省默认是0,j缺省默认是字符串长度。
阅读全文
posted @ 2020-06-17 17:06
posted @ 2020-06-17 17:06
posted @ 2019-08-08 17:24
posted @ 2018-04-12 22:57
posted @ 2018-04-12 21:31