为了账号安全,请及时绑定邮箱和手机立即绑定

如何运行影响我的变量并且不破坏我的代码的 while 循环?

如何运行影响我的变量并且不破坏我的代码的 while 循环?

一只萌萌小番薯 2021-06-13 11:14:07
我正在尝试运行一个 while 循环来更改我的代码中的变量,但它只会破坏我的代码。我不知道该怎么做。当我改变 T 而不重复命令时,我希望 X 改变。import tkinterfrom tkinter import *code = Tk()T = 1X = 0def printx():    global X    print(X);def teez():    global T    T = 0;def teeo():    global T    T = 1;while T == 1:    X = 5else:    X = 6button1 = Button(code, text = "Print X", command = printx)button1.pack()button2 = Button(code, text = "T = 0", command = teez)button2.pack()button2 = Button(code, text = "T = 1", command = teeo)button2.pack()code.mainloop()PS它在python 3.7中
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 139 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信