How to get the current time in Python

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

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

30条回答
  •  Happy的楠姐
    2020-11-22 07:15

    Similar to Harley's answer, but use the str() function for a quick-n-dirty, slightly more human readable format:

    >>> from datetime import datetime
    >>> str(datetime.now())
    '2011-05-03 17:45:35.177000'
    

提交回复
热议问题