[英]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.