[Python] Convert string to datetime object without strptime

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

  1. Stack

    Stack Membro Participativo

    So if you don't tell Python how to output a time, it does this:

    print(datetime.datetime.utcnow())
    >> 2019-06-07 13:07:55.777035


    To read a time string into a datetime object, you usually use .strptime() method and tell it what it is looking for.

    I know there are libraries like dateutil which are not part of the standard Python built-in libraries which can interpret a date string. Given that this particular string was created by standard Python without specifying anything at all about how it should be, can Python, with no non-builtin libraries get it back into a datetime.datetime object without telling strptime() what to look for?

    Continue reading...

Compartilhe esta Página