converting timedelta to float

0 votes
How do I convert the timedelta duration into float value?
Aug 8 in Python by Fata
• 1,040 points
199 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 by Wajiha
• 1,920 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 in Python by Nisa
• 1,090 points
21 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,720 points
1,661 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,720 points
55 views
+1 vote
2 answers

How to resize the image canvas to maintain a square aspect ratio

down voteacceptedUsing OpenCVYou can use resize() in OpenCV to ...READ MORE

answered Apr 4, 2018 in Python by charlie_brown
• 7,720 points
209 views
+3 votes
5 answers

How to read multiple data files in python

Firstly we will import pandas to read ...READ MORE

answered Apr 6, 2018 in Python by DeepCoder786
• 1,720 points
2,638 views
+4 votes
7 answers
0 votes
1 answer

converting string into datetime

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

answered Aug 7 in Python by Wajiha
• 1,920 points
23 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 in Python by Wajiha
• 1,920 points
314 views
0 votes
1 answer

What is timedelta in python?

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

answered Aug 7 in Python by Wajiha
• 1,920 points
32 views