例如,
Script1.py包含添加两个数字的程序。我想从script2.py调用这个文件并传递values.how它可能吗? 注意:文件script1.py未放在同一文件夹中。
SCRIPT1:
num1 = a; num2 = b;
sum = float(num1)+ float(num2)
打印(' {0}和{1}之和为{2}' .format(num1,num2,sum))
SCRIPT2:
def hello():
subprocess.Popen(['sudo', 'python','/MyRepository/services/uploaded/programmingAssignments/sum.py', '2', '2'])
答案 0 :(得分:0)
script1.py
subprocess.Popen(['python', '/home/pi/script2.py', '2', '2'])
script2.py
sum = sys.argv[1] + sys.argv[2]