[Python] Datetime in python

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    How to set format in date time in Python?

    import time

    from datetime import datetime
    s1=datetime.now()
    print s1
    time.sleep(2)
    s2=datetime.now()
    print s2

    FMT = '%Y-%m-%d %H:%M:%s'
    tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
    print tdelta

    Continue reading...

Compartilhe esta Página