Skip to content

Dealing with leading 0's on Windows #23

@NegativeZero000

Description

@NegativeZero000

I have Python 3.X installed on Windows 10. Just started learning and made it to the site looking at date representation. I got an error using the format placeholders. Attempting to use the format string '%B %-d, %-I:%M' netted me:

ValueError: Invalid format string

I figured I did something wrong but after looking at StackOverflow turns out I could have used # instead of -.

I do not know the specifics of why this is not working but I thought it would be worth mentioning somewhere that perhaps:

Note: If you using windows and encounter ValueError: Invalid format string when trying to remove leading 0's try using the ampersand in place of the hypen e.g '%B %#d, %#I:%M'

I see that string (platform specific) on the page and a link to the documentation but it was not obvious on that page what I had to do either :/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions