这行代码
print [0, 1, 2, 3, 4][0:1:1]
返回[0]。
但是,以下代码行:
print [0, 1, 2, 3, 4][0:0:1]
返回[]。
为什么是这样?基于这个Explain Python's slice notation,我的理解是格式应该是:
a[start:end:step] # start through not past end, by step
所以不应该[0, 1, 2, 3, 4][0:0:1]在第 0 个值开始和结束,从而返回[0]?