如何在Python中运行1000卷的Ezee游戏

2024-09-28 01:31:16 发布

您现在位置:Python中文网/ 问答频道 /正文

到目前为止,我已经完成了整个Ezee程序,但是我需要一次模拟1000次,而我却被困在了如何去做。这是我的代码:

<script src="//repl.it/embed/HzBl/24.js"></script>


Tags: 代码程序srcjsscriptitembedrepl
1条回答
网友
1楼 · 发布于 2024-09-28 01:31:16

如果你的意思是同时运行游戏功能1000次。然后需要执行线程:

import threading
threads = []
for i in range(1000):
    th = threading.Thread(name=str(i),target = game)
    threads.append(th)
    th.start()
for each in threads:
    each.join()

但是,由于游戏函数的设计,特别是它在运行时输出而不是返回要输出的值,线程问题可能会发生。在

编辑

我已经在您的代码中编辑并实现了它:

^{pr2}$

相关问题 更多 >

    热门问题