类型错误:'builtin_function_or_method'对象不可自订
for x in values: x = header.index["NoExamples*NoFeatures"]
print (x)
当我写这段代码时,第二行有错误。类型错误:'builtin_function_or_method'对象不可自订
"TypeError: 'builtin_function_or_method' object is not subscriptable"。
你能帮我解答吗?
回答:
推测地,header是sequence(例如list)并且index是用于发现元素的第一次出现的内建方法。问题在于你试图用方括号([])调用该方法,这是用于索引的Python语法,而不是括号。正确的语法应为:
x = header.index("NoExamples*NoFeatures") ,这将给你的字符串"NoExamples*NoFeatures"第一次出现的索引序列header英寸
以上是 类型错误:'builtin_function_or_method'对象不可自订 的全部内容, 来源链接: utcz.com/qa/262257.html

