python - 为什么 str[64:] 有效而 str[64] 无效?
问题描述
假设您有一个名为 s 的字符串:
s = "000000000000000000000000000000000000000000000000000000000000000"
len(s)
#63
当您运行s[64:]
时,Python 编译器会返回''
。
但是,当您运行s[64]
代码时会引发以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
为什么会这样?
提前致谢。
解决方案
推荐阅读
- java - java websockets和ping
- command - 连续 CMS ERROR:500 with Huawei E180 after some SMS sent
- python - Python append_sum(lst)
- coq - sumbool 和 sum 的区别
- java - Jackson 可以在(de)/序列化期间使用具有 java.util.Map 中包含的属性的构建器吗?
- php - Wordpress 自定义批量操作处理程序未触发
- python - TensorFlow:GradientDescentOptimizer 给出 nan 输出
- java - 例外:在 Android OREO 中的 android.graphics.drawable.AdaptiveIconDrawable.isProjected
- c# - 添加 for 循环时将重复行添加到数据网格
- meteor - Meteor version1.7.0.5 错误 - 将应用程序更新到最新版本后无法对模块“../lib/utils.js”进行优化