Is there an easy way to convert ISO 8601 duration to timedelta?
<p>Given a ISO 8601 duration string, how do I convert it into a <code>datetime.timedelta</code>?</p>
<p>This didn't work:</p>
<pre><code>timedelta(&quot;PT1H5M26S&quot;, &quot;T%H%M%S&quot;)
</code></pre>
<p>A timedelta object represents a duration, the difference between two dates or times (<a href="https://docs.python.org/3/library/datetime.html#datetime.timedelta" rel="noreferrer">https://docs.python.org/3/library/datetime.html#datetime.timedelta</a>). ISO 8601 durations are described here: <a href="https://en.wikipedia.org/wiki/ISO_8601#Durations" rel="noreferrer">https://en.wikipedia.org/wiki/ISO_8601#Durations</a></p>