我正在努力在输出中打印时间。我想运行该程序并记下每个迭代时间。我想我缺少主体。我是编程新手。
导入itertools 将熊猫作为pd导入 导入时间
df
nb_people group
0 8 GROUP C
1 3 GROUP B
2 4 GROUP B
3 2 GROUP A
答案 0 :(得分:0)
如果我理解正确,您只需要缩进打印输出,以便将其应用于循环中的所有通道,而不仅限于最后一个循环:
for i in range(0,1):
start = time.time()
print 'iteration: ', i
end = time.time()
print "Time is taken by the Solver", end-start
f.write("Iteration: "+str(i)+','+str(end-start)+'\n') # << Extra tab at start of line here makes this happen for each pass through your for loop