Converting utc time string to datetime object

后端 未结 4 1986
失恋的感觉
失恋的感觉 2021-01-01 11:23

I\'m using the Paypal API and I get back a timestamp in the following format. It try to parse this to a datetime object using strptime, but I get the following error:

<
4条回答
  •  误落风尘
    2021-01-01 11:48

    The problem is that you use %M twice. Use %m for the months:

    >>> datetime.strptime('2012-03-01T10:00:00Z','%Y-%m-%dT%H:%M:%SZ')
    datetime.datetime(2012, 3, 1, 10, 0)
    

提交回复
热议问题