TypeError string indices must be integers not tuple 的意思
这个错误意味着你尝试在一个字符串上使用一个元组作为索引。字符串的索引必须是整数,不能是元组。
可能的原因是你以元组的形式使用了字符串的索引,例如:
string = "Hello"
index = (0, 1, 2)
print(string[index])
如果你想使用多个索引来访问字符串的特定字符,你应该使用整数索引而不是元组。例如:
string = "Hello"
index = 0
print(string[index]) # 输出:H
请检查你的代码,确保在字符串上使用整数索引。
原文地址: https://www.cveoy.top/t/topic/hycY 著作权归作者所有。请勿转载和采集!