[英]How can I run another Python script in a Python script?
I would like to run a Python script in another Python script.我想在另一个 Python 脚本中运行一个 Python 脚本。 I understand that the best way to do that is importing that script.我知道最好的方法是导入该脚本。 But I couldn't figure out how I can run that script every 60 seconds.但我不知道如何每 60 秒运行一次该脚本。 What I have tried so far:到目前为止我尝试过的:
import time
import mailyolla
while(1):
mailyolla
time.sleep(60)
and和
import time
while(1):
import mailyolla
time.sleep(60)
Neither worked.都没有工作。 What should I do?我该怎么办?
You should define a main() function in your mailyolla file that is executing the task you want.您应该在执行您想要的任务的 mailyolla 文件中定义一个 main() 函数。 Then, the above script would look like:然后,上面的脚本看起来像:
import time
import mailyolla
while(True):
mailyolla.main()
time.sleep(60)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.