-4

Is there a way to time the amount of time that happened between (for example) button a being pressed and button b being pressed in Python? If so, how?

Thanks for any help.

Bill Reason
  • 391
  • 1
  • 5
  • 13

2 Answers2

2

You dislike to search before ask, isnt't it? there is a module surprisingly called time

import time
start = time.time()
for i in range(10):
    print i
stop = time.time()
print 'elapsed time in seconds', stop - start
am2
  • 380
  • 5
  • 21
1

You can use the time function

import time

start = time.time()
#do stuff
end = time.time()
logger.debug("time:{0}".format(end-start))
Don Smythe
  • 9,234
  • 14
  • 62
  • 105