date:如何进入python当前时间?

How to get on python current time?

本问题已经有最佳答案,请猛点这里访问。

我需要有个约会。时间格式为2017-01-18T07:34:35Z我试过了,但没有成功:

1
2
3
import datetime
i = datetime.datetime.now()
date = %i.year"-" %i.month"-" %i.day"T" %i.hour":" %i.minute":" %i.second"Z"


1
2
3
4
5
from time import gmtime, strftime
strftime("%a, %d %b %Y %H:%M:%S", gmtime())

# Will output
'Thu, 03 May 2017 16:21:01'

例如:

1
2
3
from time import gmtime, strftime
strftime("%y-%d-%mT%H:%M:%SZ", gmtime())
2017-03-05T07:34:35Z

1
2
3
    import time

    now = time.strftime("%c")

更多信息请访问https://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/