How to calculate time interval between two time strings in Python

0 votes
Need to find the difference between the two times, how do I do this?

Do I use the date/time module?

My goal is to calculate the averages of multiple time duration. I am thinking for storing them in a list and later need to calculate the average. For the averaging, should I convert to seconds and then average?
Nov 29, 2018 in Python by Anirudh
• 2,050 points

edited Dec 11, 2018 by Anirudh 74 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Try doing this - It is efficient for timing short-term events.

import time
start = time.time()

time.sleep(10)  # or anything

done = time.time()
elapsed = done - start
print(elapsed)
answered Nov 29, 2018 by Nymeria
• 3,500 points

edited Dec 11, 2018 by Nymeria

Related Questions In Python

0 votes
1 answer

how to compare two strings in python?

compare two string in python >>> s1="abc ...READ MORE

answered Mar 25 in Python by rajesh
• 1,210 points
18 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2 in Python by anonymous
100 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8 in Python by rajesh
• 1,210 points
34 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,570 points
20 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
+4 votes
6 answers
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,500 points
99 views
0 votes
1 answer

How to activate virtualenv in Python? Help!

One major issue I see is that ...READ MORE

answered Nov 5, 2018 in Python by Nymeria
• 3,500 points

edited Dec 17, 2018 by Nymeria 67 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.