gpt4 book ai didi

python - 树莓派 : How To Run A Python File From another file

转载 作者:太空宇宙 更新时间:2023-11-04 06:41:26 25 4
gpt4 key购买 nike

当 python 代码到达特定点时,我有一个 python 代码正在运行(A.py)我必须运行(B.py),而 A.py 仍在后台运行

A.py

count = 1
while True:
count++
if(count%20 == 0)
//run b
print "A is running"

B.py

  x = 0
while x < 10
print "B is running"

答案必须像

A is running A is running ... 46 times repeat A is running A is running A is running B is running B is running A is running B is running A is running

A和b运行不必同步

最佳答案

import subprocess
count = 1
while True:
count+=1
if(count%20 == 0):
subprocess.Popen("python B.py")
print ("A is running")

关于python - 树莓派 : How To Run A Python File From another file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43588180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com