[Python] Error in the date time format in Python

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    My Python code is showing an error in the date time format. What should be the correct format for this type of date: '09-Jul-11 12:00:00 AM'? The date is taken as a string from a text file. This is the code I used for date and time.

    date=datetime.datetime.strptime(date, "%d-%B-%y %H:%M:%S %p")


    This was the error I got.

    ValueError: time data '09-Jul-11 12:00:00 AM' does not match format '%d-%B-%y %H:%M:%S %p'


    P.S.: I am using Python 3.

    Continue reading...

Compartilhe esta Página