繁体   English   中英

python 列表错误:IndexError:字符串索引超出范围

[英]python list error:IndexError: string index out of range

我正在尝试制作一个脚本来帮助我在我的世界中构建东西。
它从来没有奏效。
我需要帮助。
我不知道该尝试什么。
python 文件给我错误:

https://pastebin.com/Q9Vm4yfk

test.ch&bpy:

2 2 2 2 2 2 2 1 2 1 1 2 2 2 1 2 1 1 2 1 1 1 1 2 1 1 2 2 2 2 2 2 2 
2 1 1 1 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 1 2 

错误:

(env) me@some-mac qrctochbqr % python3 /Users/myname/env/qrctochbqr/buildtest.py
    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
        self.run()
      File "/Users/myname/env/qrctochbqr/buildtest.py", line 48, in run
        print(self.irtbb[self.wv1])
    IndexError: string index out of range

错误“字符串索引超出范围”仅表示您正在尝试从不存在的 position 中获取元素。 例如,如果您有一个字符串

str = "你好世界",

并且您正在尝试从该字符串中获取索引为 100 的字符:

字符 = str[100],

您当然会遇到问题,因为您的字符串没有 100 个字符。 因此,go 检查为什么您尝试获取的索引不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM