Home  >  Q&A  >  body text

datetime - How to get current time in Python

How to get the current time in Python, the format is as follows:

2017-06-23 22:12:35
ringa_leeringa_lee2694 days ago1268

reply all(1)I'll reply

  • 阿神

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

    Reference article: Get the current time in Python

    time module (low level)

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

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

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

    reply
    0
  • Cancelreply