for x in values:
x = header.index["NoExamples*NoFeatures"]
print (x)
当我写这个代码时,第二行有一个错误。
"TypeError: 'builtin_function_or_method' object is not subscriptable"
。
你能帮帮我吗?
据推测,header
是sequence(例如list
),而index
是找到第一次出现的元素的内置方法。问题是你试图用方括号([]
)调用方法,这是用于索引的Python语法,而不是括号。正确的语法应该是:
x = header.index("NoExamples*NoFeatures")
这将为您提供"NoExamples*NoFeatures"
序列中第一次出现的字符串header
的索引。