How to get the current time in Python

前端 未结 30 2042
滥情空心
滥情空心 2020-11-22 06:47

What is the module/method used to get the current time?

30条回答
  •  梦谈多话
    2020-11-22 07:25

    >>> from time import gmtime, strftime
    >>> strftime("%a, %d %b %Y %X +0000", gmtime())
    'Tue, 06 Jan 2009 04:54:56 +0000'
    

    That outputs the current GMT in the specified format. There is also a localtime() method.

    This page has more details.

提交回复
热议问题