使用列表切片和“+”运算符这是如何工作的?
Using list slicing and “+” operator how this work?
S=len(s)
i=0
while i<S:
fwd=s[i:]+s[1:i]
print(fwd)
i+=1
I want to know the working of fwd = s[i:]+s[1:i]
假设 i = 2 和 s = [0, 1, 2, 3, 4, 5]。首先它执行 s[2:](2, 3, 4, 5) + s1:2。那么它的 [2, 3, 4] + [1] = [2, 3, 4, 1]
S=len(s)
i=0
while i<S:
fwd=s[i:]+s[1:i]
print(fwd)
i+=1
I want to know the working of fwd = s[i:]+s[1:i]
假设 i = 2 和 s = [0, 1, 2, 3, 4, 5]。首先它执行 s[2:](2, 3, 4, 5) + s1:2。那么它的 [2, 3, 4] + [1] = [2, 3, 4, 1]