登陆

datetime - Python如何获取当前时间

Python如何获取当前时间,格式如下:

2017-06-23 22:12:35
# Python
ringa_leeringa_lee1581 天前826 次浏览

全部回复(1)我要回复

  • 阿神

    阿神2017-06-28 09:27:57

    参考文章:Python获取当前时间

    time模块(low level)

    import time
    time.strftime("%Y-%m-%d %H:%M:%S")

    datetime模块(high level Object-oriented interface to dates and times)

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

    回复
    0
  • 取消回复发送