I get that error on Python 2, but Python 3 works fine. Given that Python 2 is EOL you probably want to update to Python 3.
py3:
In [22]: datetime.datetime.strptime('Sun, 12 Apr 2020 23:04:52 +0000', '%a, %d %b %Y %H:%M:%S %z')
Out[22]: datetime.datetime(2020, 4, 12, 23, 4, 52, tzinfo=datetime.timezone.utc)
py2:
>>> datetime.datetime.strptime('Sun, 12 Apr 2020 23:04:52 +0000', '%a, %d %b %Y %H:%M:%S %z')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/_strptime.py", line 324, in _strptime
(bad_directive, format))
ValueError: 'z' is a bad directive in format '%a, %d %b %Y %H:%M:%S %z'