What are the default slice indices in Python *really*?

后端 未结 6 1720
死守一世寂寞
死守一世寂寞 2020-11-30 11:53

From the python documentation docs.python.org/tutorial/introduction.html#strings:

Slice indices have useful defaults; an omitted first index defaults

6条回答
  •  鱼传尺愫
    2020-11-30 12:23

    I don't have any documentation, but I think the default is [None:None:None]

    >>> "asdf"[None:None:None]
    'asdf'
    >>> "asdf"[None:None:-1]
    'fdsa'
    

提交回复
热议问题