Python - Formatting codes & escape characters

 0    32 flashcards    sir
download mp3 print play test yourself
 
Question Answer
Left aligns the result (within the available space)
start learning
:<
Right aligns the result (within the available space)
start learning
:>
Center aligns the result (within the available space)
start learning
:^
Places the sign to the left most position
start learning
:=
Use a plus sign to indicate if the result is positive or negative
start learning
:+
Use a minus sign for negative values only
start learning
:-
Use a space to insert an extra space before positive numbers (and a minus sign befor negative numbers)
start learning
:
Use a comma as a thousand separator
start learning
:,
Use a underscore as a thousand separator
start learning
:_
Binary format
start learning
:b
Converts the value into the corresponding unicode character
start learning
:c
Decimal format
start learning
:d
Scientific format, with a lower case e
start learning
:e
Scientific format, with an upper case E
start learning
:E
Fix point number format
start learning
:f
Fix point number format, in uppercase format (show inf and nan as INF and NAN)
start learning
:F
General format
start learning
:g
General format (using a upper case E for scientific notations)
start learning
:G
Octal format
start learning
:o
Hex format, lower case
start learning
:x
Hex format, upper case
start learning
:X
Number format
start learning
:n
Percentage format
start learning
:%
Old formatting codes:
start learning
%s, %d, %r, %a
%r -^ repr(); %a -^ repr() in Ascii
Alert
start learning
\a
Backspace
start learning
\b
Female symbol
start learning
\f
Male symbol
start learning
\v
Newline
start learning
\n
Tab
start learning
\t
Escape to hexadecimal notation
start learning
\xnn
Octal notation
start learning
\nnn

You must sign in to write a comment