Is there a way to parse the following Time without using something hacky like s.spilt() a bunch of times?
s = 'PT1H28M26S'
I would like to get:
num_mins = 88
You could use a regular expression:
>>> match = re.search(r"PT(\d+)H(\d+)M(\d+)S", s)
>>> h, m, s = map(int, match.groups())
>>> num_mins = h * 60 + m
>>> num_mins
88
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With