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.
我希望它像在 Haskell 中一样返回 [1,2,3,4,5]。
简短的回答:左边的索引是包容性的,右边是排他性的。
长答案:简短答案的原因是列表索引为零,我们注意到每个人都必须写(或忘记写)[0..size(myList) - 1]。现在我们可以改写[0..size(myList)]了。它不像 Haskell,但它像 Python。
[0..size(myList) - 1]
[0..size(myList)]