gpt4 book ai didi

python - 在python中选择子序列混淆

转载 作者:太空宇宙 更新时间:2023-11-04 09:11:23 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
The Python Slice Notation

我对 python 子序列选择的工作方式感到困惑。假设我有以下代码:

>>> t = 'hi'
>>> t[:3]
'hi'
>>> t[3:]
''
>>> print t[:3] + t[3:]
hi
>>> print t[3]

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
print t[3]
IndexError: string index out of range

请解释一下这个东西在python中是如何工作的

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com