[Python] Python - Convert String date "17 Apr" to Date "17-04-2018"

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

  1. Stack

    Stack Membro Participativo

    I've this string variable: date_string = "17 Apr"

    How can I get this: 17-04-2018?

    I'm trying with this

    datetime_object = datetime.strptime(date_string, "%d %B")


    But I'm getting:

    builtins.ValueError: time data '17 Apr' does not match format '%d %B


    Thanks!

    Continue reading...

Compartilhe esta Página