为什么python 2.7在UTC日期时间对象的isoformat字符串末尾不包含Z字符(Zulu或零偏移量)?
>>> datetime.datetime.utcnow().isoformat()
'2013-10-29T09:14:03.895210'
Run Code Online (Sandbox Code Playgroud)
而在javascript中
>>> console.log(new Date().toISOString());
2013-10-29T09:38:41.341Z
Run Code Online (Sandbox Code Playgroud) 我必须将时区感知字符串转换为python datetime对象.
例如2012-11-01T04:16:13-04:00.
我发现有一个dateutil模块具有解析函数来执行它,但我真的不想使用它,因为它添加了一个依赖项.
那我该怎么办呢?我尝试了类似下面的东西,但没有运气.
datetime.datetime.strptime("2012-11-01T04:16:13-04:00", "%Y-%m-%dT%H:%M:%S%Z")
Run Code Online (Sandbox Code Playgroud)