1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python datetime formatting without zero-padding

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

  1. Stack

    Stack Membro Participativo

    Is there a format for printing Python datetimes that won't use zero-padding on dates and times?

    Format I'm using now:

    mydatetime.strftime('%m/%d/%Y %I:%M%p')


    Result: 02/29/2012 05:03PM
    Desired: 2/29/2012 5:03PM

    What format would represent the month as '2' instead of '02', and time as '5:03PM' instead of '05:03PM'

    Continue reading...

Compartilhe esta Página