我试图通过将num_runs设置为3来运行这个python代码。它只运行一次。它运行两次,但只有第一个文件包含数据。
import random
from math import sqrt
import subprocess
import time
# Set clock
START=time.clock()
# Simulation Parameters - num_real_runs is needed to set the range command in python
num_runs=3
# Counter Variable for total numbers of runs
running=1
while (running<num_runs):
# Execute mcell Part1
subprocess.call("mcell -seed "+str(running)+" Scene.main_1.mdl", shell=True)
# Execute mcell Part2
subprocess.call("mcell -seed "+str(running)+" Scene.main_2.mdl", shell=True)
# Calculate elapsed time for executing python script only (in min)
END=time.clock()
ELAPSED=(END-START)
print "Man, it took me only", ELAPSED, "seconds to run the python code!"
running+=1
答案 0 :(得分:1)
它只运行两次,因为在第三次通过循环时,3不小于3.将while
语句更改为:
while (running<=num_runs):