我有以下代码:
def base(nomor)
day = localtime.tm_wday
time = localtime.tm_hour
no = str(nomor)
dosen = cek_dosen(no)
if dosen == 'null':
no_dosen()
elif dosen != 'null':
ada_dosen()
matkul = cek_jadwal(day,time,dosen)
if matkul == 'null':
no_jadwal()
elif matkul != 'null':
ada_jadwal()
pertemuan = cek_pertemuan(matkul)
print pertemuan
if pertemuan > 1:
cek_before(pertemuan)
filename = ''.join([dosen, matkul, str(pertemuan), ".pptx"])
else:
filename = ''.join([dosen, matkul, str(pertemuan), ".pptx"])
grabfile(filename)
os.system(''.join(["loimpress ",filename]))
pertemuan = pertemuan + 1
update_pertemuan(pertemuan,matkul)
mulai()
if __name__ == '__main__':
mulai()
while True:
data = port.read()
count += 1
if count == 1:
if str(data) != start:
nomor = ''
count = 0
elif 2 <= count <= 13:
nomor = nomor + str(data)
elif count == 16 and str(data) == stop:
base(nomor)
nomor = ''
count = 0
我想计算从data = port.read()
之后到grabfile(filename)
之后经过的时间。我在data = port.read
之后使用了start = time.time()
,在grabfile
之后使用了end = time.time()
,time = end - start
,但是它在data = port.read()
之后仍然存在,所以我使用Ctrl+C来停止。如果我把start = time.time()
放在no = str(nomor)
之后,我得到Attribute Error : 'int' object has no attribute 'time'
。你知道吗
我如何计算经过的时间?你知道吗
看看pythontimeit module。你知道吗
基本示例:
摘要:
相关问题 更多 >
编程相关推荐