首頁  >  問答  >  主體

datetime - Python如何取得目前時間

Python如何取得目前時間,格式如下:

2017-06-23 22:12:35
ringa_leeringa_lee2646 天前1237

全部回覆(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
  • 取消回覆