[英]python list error:IndexError: string index out of range
我正在嘗試制作一個腳本來幫助我在我的世界中構建東西。
它從來沒有奏效。
我需要幫助。
我不知道該嘗試什么。
python 文件給我錯誤:
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.