python - 为什么python中的IF会输出错误?
问题描述
我在 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))
推荐阅读
- javascript - 在 Fetch 期间显示加载进度
- macos - VideoToolbox 硬件编码器帧延迟
- javascript - 使用 URL 映射对象以返回对象
- reactjs - 每次当我的 redux 状态更新时,我的整个页面都在加载。不完全从服务器加载资源,但
- layout - 如何配置最小高度非常低的chart.js折线图,并且y轴上只有0和1(无小数)作为刻度
- git - 通过合并提交恢复更改并稍后重新合并
- python - 如果数字在列表中,熊猫会创建列
- r - 对于每个 ID,打印新数据框中第二列的项目顺序(R 或 Python)
- r - 计算R中组()内所有观察值之间的成对差异的平均值?
- parsing - 解析时如何跳过指定的符号