我在更新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