y
我想收到我在 python shell 中键入的两次运行之间的时间(以秒为单位) 。
很抱歉之前我没有具体说明我想要它是什么。基本上这是我正在测试在另一个大程序(比这个大)中实现的程序。
这是我想要的输出:
首先,我将运行该程序,它会询问我是否要借用,然后单击y
。之后,我将再次运行该程序,它会要求我返回,我将再次单击y
,它应该以秒为单位返回我借用的时间。循环将继续。
这是我需要的图书馆管理系统程序。
import time
import csv
data_backup1=[]
f=open("a1.csv",'r')
csvr=csv.reader(f)
for line in csvr:
#copying data into a temporary storage area from csv file
print(line)
data_backup1.append(line)
print(csvr,"this is csvr")
f.close()
l=[]
if len(data_backup1)==0:
f=open("a1.csv",'w')
csvw=csv.writer(f)
a=input("Enter y to borrow")
if a=="y":
m="borrowing"
l.append(m)
print(l)
print("this is l")
n=time.time()
l.append(n)
print(l)
print("this is l")
csvw.writerow(l)
f.close()
f.close()
f=open("a1.csv",'r')
csvr=csv.reader(f)
for line in csvr:
print(line)
else:
a=input("Enter y to return")
if a=="y":
c=[]
f=open("a1.csv",'r')
csvr=csv.reader(f)
c=csvr[1]
print(c,"this is c")
b=c[1]
print(b,"this is b")
b=int(b)
print(time.time()-b)
f.close()
f=open("a1.csv",'w')
f.close()
我想得到一些建议。
这是我在两次运行之间实际得到的。请注意,我已经创建了a1.csv.
万千封印
相关分类