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,080 points

edited Dec 11, 2018 by Anirudh 2,931 views

1 answer to this question.

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,560 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, 2019 in Python by rajesh
• 1,270 points
905 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, 2019 in Python by anonymous
5,352 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, 2019 in Python by rajesh
• 1,270 points
1,699 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,830 points
521 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,057 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,477 views
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,560 points
1,932 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,560 points

edited Dec 17, 2018 by Nymeria 4,255 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP