请教下各位, python 中这种时间格式
a1 = datetime.datetime.utcnow()
print a1
2015-11-16 09:48:19.403063
如何转换为这种格式
2015-11-16T09:48Z
求解答,谢谢
1
iptux 2015-11-17 00:38:18 +08:00 via Android 1
help(datetime.datetime.strftime)
|
2
wico77 2015-11-17 00:39:29 +08:00
rfc386
|
4
imkh OP >>> datetime.datetime.strftime(a1,"%Y-%m-%dT%H:%MZ")
'2015-11-16T16:44Z' >>> a1 = datetime.datetime.utcnow() >>> print a1 2015-11-16 16:50:19.147045 >>> a2 = datetime.datetime.strftime(a1,"%Y-%m-%dT%H:%MZ") >>> print a2 2015-11-16T16:50Z |
5
mimzy 2015-11-17 01:00:26 +08:00
>>> a1 = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%MZ")
>>> print a1 2015-11-16T16:59Z 顺便也学了下… |
6
mrqyoung 2015-11-19 20:44:29 +08:00
>>> import datetime
>>> a1 = datetime.datetime.utcnow() >>> a1.isoformat() '2015-11-19T12:45:09.390330' >>> a1.isoformat()[:16] + 'Z' '2015-11-19T12:45Z' |