iswbm / magic-python

Python 黑魔法手册

Home Page:http://magic.iswbm.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

c01/c01_24

utterances-bot opened this issue · comments

1.24 时有时无的切片异常 — Python黑魔法手册 1.0.0 documentation

https://magic.iswbm.com/c01/c01_24.html

類似於

>>> alist = [0, 1, 2, 3, 4]
>>> alist[:100]
[0, 1, 2, 3, 4]

在切片里 list[a:b] 如果a或者b大于列表长度 则默认改成列表长度 如果a>b 就让b会把b改成跟a相等 印象中是这样