问题描述
elif( listb[0] == "-test"):run_all.set("testview")listb.pop[0]
错误:Tkinter 回调 Traceback 中的异常(最近一次调用最后):文件/tools/python/2.7.2/lib/python2.7/lib-tk/Tkinter.py",第 1410 行,在通话return self.func(*args) File "./edit.py", line 581, in populatelistb.pop[0] TypeError: 'builtin_function_or_method' 对象不可下标
#581 行由上面代码中的最后一个 pop 语句表示.run_all 是一个 StringVar.
为什么我会收到此错误以及如何解决?
我想你想要
listb.pop()[0]
表达式 listb.pop
是一个有效的 Python 表达式,它导致对 pop
方法的引用,但实际上并不调用该方法.您需要添加左括号和右括号才能调用该方法.
elif( listb[0] == "-test"):
run_all.set("testview")
listb.pop[0]
The line # 581 is represented by last pop statement in the code above.run_all is a StringVar.
Why am I getting this error and how can it be solved?
I think you want
listb.pop()[0]
The expression listb.pop
is a valid python expression which results in a reference to the pop
method, but doesn't actually call that method. You need to add the open and close parentheses to call the method.
这篇关于类型错误:'builtin_function_or_method' 对象不可下标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!