aug*_*rar 7 python slice python-3.x
有没有办法在Python 3中创建一个序列的"切片视图",其行为类似于常规切片但不创建序列切片部分的副本?更新原始序列时,"切片视图"应反映更新.
>>> l = list(range(100))
>>> s = Slice(l, 1, 50, 3) # Should behave like l[1:50:3]
>>> s[1]
4
>>> l[4] = 'foo'
>>> s[1] # Should reflect the updated value
'foo'
Run Code Online (Sandbox Code Playgroud)
我可以编写我自己的Slice类,但我想知道是否有内置方式.