How to get the current time in Python

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

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

30条回答
  •  故里飘歌
    2020-11-22 07:38

    from datetime import datetime
    datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    

    For this example, the output will be like this: '2013-09-18 11:16:32'

    Here is the list of strftime directives.

提交回复
热议问题