How to get the current time in Python

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

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

30条回答
  •  太阳男子
    2020-11-22 07:29

    If you need current time as a time object:

    >>> import datetime
    >>> now = datetime.datetime.now()
    >>> datetime.time(now.hour, now.minute, now.second)
    datetime.time(11, 23, 44)
    

提交回复
热议问题