问题在注释里
import tkinter as tk
def on_off():
global button
state = button.cget("text")#这里的property为什么要用引号?如果直接button.cget(text)会报错,这是什么原因?
if state == "ON":
state = "OFF"
else:
state = "ON"
button.config(text=state)
window = tk.Tk()
button = tk.Button(window, text="OFF", command=on_off)
button.place(x=50, y=100, width=100)
window.mainloop()
```