基本上,我有一些这样的代码:
while True:
number = int(len(oilrigs)) * 49
number += money
time.sleep(1)在这前面我有一个启动屏幕。然而,由于这个while true循环,它会阻止它运行实际的启动屏幕。相反,它只显示以下内容。
那么如何将代码放在后台呢?
发布于 2016-07-08 03:56:49
尝试多线程。
import threading
def background():
while True:
number = int(len(oilrigs)) * 49
number += money
time.sleep(1)
def foreground():
# What you want to run in the foreground
b = threading.Thread(name='background', target=background)
f = threading.Thread(name='foreground', target=foreground)
b.start()
f.start()https://stackoverflow.com/questions/38254172
复制相似问题