python可以多次运行线程吗?

时间:2021-01-26 08:08:16

标签: python

我在 tkinter 上做了一个按钮。

当你按下按钮时,它会被穿线并输出1。

然而,一次之后,情色代码被分发,并没有执行。

我该怎么办?

主要代码

from tkinter import Tk
import tkinter as tk
import threading

root = tk.Tk()
def test1():
    print("1")

btn1 = tk.Button(root, text="test", command=threading.Thread(target=test1).start)
btn1.pack()
root.mainloop()

错误代码

File "", line 869 in start
    raise RuntimeError("threads can only be started once")
RuntimeError: threads can only be started once

0 个答案:

没有答案
相关问题