converting timedelta to float

0 votes
How do I convert the timedelta duration into float value?
Aug 8, 2019 in Python by Fata
• 1,050 points
1,595 views

1 answer to this question.

0 votes

Use the following piece of code:

x1=datetime.timedelta(days=3000, seconds=0, microseconds=0, milliseconds=0, minutes=40, hours=5, weeks=8)
x2=datetime.timedelta(days=345, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=4, weeks=8)
x3=x1-x2
x5 = x3.total_seconds()
print(x5)

OUTPUT:

229398000.0
answered Aug 8, 2019 by Wajiha
• 1,950 points

Related Questions In Python

+1 vote
1 answer

Converting integers to strings

Yes you can convert integers to strings ...READ MORE

answered Jul 1, 2019 in Python by Nisa
• 1,090 points
77 views
0 votes
1 answer

How do I parse a string to a float or int?

Hii, Python method to check if a string ...READ MORE

answered Apr 13 in Python by Niroj
• 59,640 points
87 views
0 votes
1 answer

How to check if a float value(decimal number) is between range(0 to 10) in python

Hello,  A function that returns True for an integer number (int or ...READ MORE

answered Sep 13 in Python by Niroj
• 59,640 points
98 views
0 votes
1 answer

How to list a column of float values from csv file without importing (Python)

Using the default CSV module Demo: import csv with open(filename, "r") ...READ MORE

answered Sep 16 in Python by Rajiv
• 2,620 points
38 views
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,780 points
2,695 views
+2 votes
2 answers

How to use BeatifulSoup for webscraping?

your programme is fine until you start ...READ MORE

answered Apr 4, 2018 in Python by charlie_brown
• 7,780 points
183 views
0 votes
1 answer

converting string into datetime

You can make use of asctime() method ...READ MORE

answered Aug 7, 2019 in Python by Wajiha
• 1,950 points
79 views
0 votes
1 answer

timedelta in years

Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, ...READ MORE

answered Aug 8, 2019 in Python by Wajiha
• 1,950 points
4,807 views
0 votes
1 answer

What is timedelta in python?

It represents a duration which is basically ...READ MORE

answered Aug 7, 2019 in Python by Wajiha
• 1,950 points
87 views