小编k33*_*33n的帖子

为什么切片表达式会生成该输出

我懂了:

#slicing: [start:end:step]
s = 'I am not the Messiah'
#s[0::-1] = 'I'
Run Code Online (Sandbox Code Playgroud)

所以在这种情况下

start=0, end=0, step=-1
Run Code Online (Sandbox Code Playgroud)

为什么是

s[0::-1] == 'I'
>>>> True
Run Code Online (Sandbox Code Playgroud)

python slice

6
推荐指数
1
解决办法
62
查看次数

标签 统计

python ×1

slice ×1