Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有这个代码:
a = [1, 2, 3, 4, 5] a[2:4:-1] # returns [] a[4:2:-1] # returns [5, 4]
a[2:4:-1]尽管指定了范围,但为什么语句返回一个空列表?
a[2:4:-1]
如果您尝试使用a[2:4:-1],请尝试从列表索引向后退到2显然4不起作用。
2
4