24

I've been looking for the list Python format characters for a good 30 minutes. I can't find any.

Examples are

%d, %r

etc but I need a list with them along with a description if possible please.

2

3 Answers 3

32

Here you go, Python documentation on old string formatting. tutorial -> 7.1.1. Old String Formatting -> "More information can be found in the [link] section".

Note that you should start using the new string formatting when possible.

2
  • 5
    You should use new string formatting when appropriate; there are a great many cases where standard string formatting is much more appropriate. Commented Dec 19, 2010 at 1:54
  • 1
    The actual list of format characters can be found here (under 'type').
    – djvg
    Commented Apr 13, 2018 at 7:51
7

It's the first result on Google: http://docs.python.org/library/stdtypes.html#string-formatting

See also the new format() function: http://docs.python.org/library/stdtypes.html#str.format

2
  • 5
    It's the first result on Google no matter what you search for? Need to give the search terms you used, so Freddie Rice has a chance to learn how to improve (as marcog did on a comment on the question).
    – Fred Nurk
    Commented Dec 18, 2010 at 23:09
  • Heh, yeah. My first hit brought me here. Commented May 24, 2013 at 19:23
6

In docs.python.org Topic = 5.6.2. String Formatting Operations http://docs.python.org/library/stdtypes.html#string-formatting then further down to the chart (text above chart is "The conversion types are:")

The chart lists 16 types and some following notes.

My comment: help does not include attitude which is a bonus. The attitude post enabled me to search further and find the info.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.