1

I want to convert a string in the following format to a datetime object in Python.

'2019-11-08T13:22:19.173700864-05:00'

I tried to use:

obj = datetime.strptime('2019-11-08T13:22:19.173700864-05:00', '%Y-%m-%dT%H:%M:%S.%f000%z')

I got an error message. It seems %f000 is not the correct way to convert 9-digit after the decimal point. And it seems I am also using %z in the wrong way.

What is the correct way to do this? Thanks.

Leopold
  • 111
  • 3

0 Answers0