![](/img/trans.png)
[英]In Python, how can I run another Python script from the main script at the same time and close it when I stop the main script?
[英]How can I run another Python script in a Python script?
我想在另一个 Python 脚本中运行一个 Python 脚本。 我知道最好的方法是导入该脚本。 但我不知道如何每 60 秒运行一次该脚本。 到目前为止我尝试过的:
import time
import mailyolla
while(1):
mailyolla
time.sleep(60)
和
import time
while(1):
import mailyolla
time.sleep(60)
都没有工作。 我该怎么办?
您应该在执行您想要的任务的 mailyolla 文件中定义一个 main() 函数。 然后,上面的脚本看起来像:
import time
import mailyolla
while(True):
mailyolla.main()
time.sleep(60)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.