[英]Raspberry pi : How To Run A Python File From another file
I have one python code running (A.py) when the python code reach a specific point i must run (B.py) while A.py is still running on the background 当python代码到达特定点时,我必须运行一个python代码(A.py),而A.py仍在后台运行时我必须运行(B.py)
A.py py
count = 1
while True:
count++
if(count%20 == 0)
//run b
print "A is running"
B.py py
x = 0
while x < 10
print "B is running"
Answer must be like 答案一定像
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正在运行A正在运行... 46次重复A正在运行A正在运行A正在运行B正在运行B正在运行A正在运行B正在运行A正在运行
A and b running does not have to be synchronized A和B的运行不必同步
import subprocess
count = 1
while True:
count+=1
if(count%20 == 0):
subprocess.Popen("python B.py")
print ("A is running")
if(count%20 == 0):
execfile('B.py')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.