文章详情页
python同时执行两个函数
浏览:244日期:2022-06-28 08:08:57
问题描述
我现在自定义了两个函数
def test():
while True: ... ...
def test1():
while True: ... ...
这两个函数都是一个无限循环的两个函数,我现在想让这两个函数在同一个PY文件中去同时执行,不知道大佬们有什么好的解决方法呢。新手求教。
问题解答
回答1:多线程 threading
import threadingthreading.Thread(target= test).start()threading.Thread(target=test1).start()
相关文章:
1. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?2. docker api 开发的端口怎么获取?3. docker镜像push报错4. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?5. PHP中的$this代表当前的类还是方法?6. macos - mac下docker如何设置代理7. 老师,flex-shrink: 1; 按视频操作,不会自动缩放8. 前端 - 类到底该如何去命名 .newsList 这种的命名难道真的不是过度语义化吗?~9. sublime-text - sublime text 3中编译python(sublimeREPL),如何仅运行单行/选定部分10. android glide asbitmap 在baseadpter中的问题
排行榜

网公网安备