I have a string that represents the timedelta in the format X days HH:MM:SS.
Eg :
0 days 00:10:07
1 days 00:01:02
I want to convert it to
- python
datetime.timedeltaformat. - Minutes (i.e in above example it would say 10 mins and second example 1 day*60*24+1 hour *60 = 1500)
Can I use strptime method to parse it and convert to correct format? If not that, is there a way without using reg-ex re module ?
Edit :
A similar question on stack-overflow explains the usage of
strptimemethod. However it assumes that the input is a specificdatetime.In my case, the interval is given as a
timedeltabut in string
format.The top voted answer uses the regex - I prefer to use the inbuilt datetime library to parse unless it cannot be done without regex