相关疑难解决方法(0)

了解切片表示法

我需要在Python的切片表示法上有一个很好的解释(引用是一个加号).

对我来说,这种符号需要一点点提升.

它看起来非常强大,但我还没有完全了解它.

python iterable list slice

3024
推荐指数
33
解决办法
159万
查看次数

为什么子串切片索引超出范围在Python中有效?

为什么不'example'[999:9999]导致错误?既然'example'[9]做,什么是其背后的动机是什么?

从这种行为我可以假设'example'[3],基本上/内部,不一样'example'[3:4],即使两者都产生相同的'm'字符串.

python string substring

72
推荐指数
3
解决办法
2万
查看次数

为什么python的列表切片不会产生索引超出范围的错误?

在使用数组切片时,我注意到切片a[index:] or a[:index]类型不会为字符串生成数组索引超出绑定的错误.

str = "abcde"
print str[10:]
print str[:10]
Run Code Online (Sandbox Code Playgroud)

产生输出:

''
abcde
Run Code Online (Sandbox Code Playgroud)

谁能解释为什么?它不应该产生数组索引越界错误?如果我尝试执行以下操作,Python确实会产生此错误:print str[10].

python string list slice python-2.7

12
推荐指数
1
解决办法
4925
查看次数

标签 统计

python ×3

list ×2

slice ×2

string ×2

iterable ×1

python-2.7 ×1

substring ×1