将UTC时间字符串转换为日期时间对象 [英] Converting utc time string to datetime object

查看:47
本文介绍了将UTC时间字符串转换为日期时间对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Paypal API,我得到了以下格式的时间戳.它尝试使用 strptime 将其解析为日期时间对象,但出现以下错误:

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:

(Pdb) datetime.strptime('2012-03-01T10:00:00Z','%Y-%M-%dT%H:%M:%SZ')
*** error: redefinition of group name 'M' as group 5; was group 2

另外,由于这种格式应该是非常标准的格式,所以没有可用的功能吗?

Also, as this format is supposed to be quite a standard format isn't there a function available for this?

好吧,好像打错了.第一个 %M 应该是 %m

Ok seems to be a typo. First %M should be %m

推荐答案

看起来你正在混合 %M(分钟)和 %m(月).

Looks like you're mixing %M (minute) and %m (month).

这篇关于将UTC时间字符串转换为日期时间对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆