【发布时间】:2018-02-22 19:28:52
【问题描述】:
我有两个脚本,new.py 和 test.py。
测试.py
import time
while True:
x = "hello"
time.sleep(1)
x = "world"
time.sleep(1)
新的.py
import time
while True:
import test
x = test.x
print(x)
time.sleep(1)
现在,据我了解,这应该在执行 new.py 时始终打印“hello”和一秒钟后的“world”。 它不打印任何东西,我该如何解决?
谢谢
【问题讨论】:
-
对不起我之前的回答......这是完全错误的。你需要线程来做这样的事情......或者只是一个while循环。在单个线程中,您不能同时处于 2 个非嵌套的 while 循环中。
标签: python python-3.x