我在更新tkinter中的标签时遇到问题。我查看了关于这个错误的所有其他问题,但没有一个与我的情况有关。总之,这里是我的代码:'var'是该函数的无效关键字参数? (Tkinter和Python)
var = 100
v = StringVar()
v.set(str(var))
varLabel=Label(app, textvariable=v).grid(row=0)
#this is where i update my label
#also, this is where i get the error
v.set(str(var = var - dictionary[number]))
错误说:
'var' is an invalid keyword argument for this function
任何想法,我做错了什么?
感谢
python中的'str'函数没有'var'关键字参数。 – alecxe
它看起来像你来自C派生语言(C++,Java,C#,D等等)。与那些语言不同,Python中的赋值不是表达式。您不能在函数调用或时间条件或其他任何地方为变量赋值,你只能做它自己的声明。 – abarnert