为什么 python 中的 IF 会输出错误?
Why does an IF in python outputs an error?
我正在用 tkinter 编写一个小程序,但它不起作用,因为当我按 F5 执行代码时,出现一个弹出窗口说:Tab/space error
.这是我的代码:
def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
if text2 == 0:
timerc = int(spin3.get())
timer2()
text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
if text2==0:
text3(text=(int(spin3.get())-1))
问题出在text3(text=(int(spin3.get())-1))
,但我不知道为什么。
谢谢。
有更正的代码:
def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
if text2 == 0:
timerc = int(spin3.get())
timer2()
text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
if text2==0:
text3(text=(int(spin3.get())-1))
我正在用 tkinter 编写一个小程序,但它不起作用,因为当我按 F5 执行代码时,出现一个弹出窗口说:Tab/space error
.这是我的代码:
def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
if text2 == 0:
timerc = int(spin3.get())
timer2()
text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
if text2==0:
text3(text=(int(spin3.get())-1))
问题出在text3(text=(int(spin3.get())-1))
,但我不知道为什么。
谢谢。
有更正的代码:
def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
if text2 == 0:
timerc = int(spin3.get())
timer2()
text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
if text2==0:
text3(text=(int(spin3.get())-1))