$s and %d in python

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Jun 30 22:30:12 EDT 2018


Cameron Simpson wrote:
> The variable my_height is an int, and for an int both these things are 
> the same.

But note that 'd' and 's' can give different results when
other formatting options are present, e.g.

 >>> "%05d" % 42
'00042'
 >>> "%05s" % 42
'   42'

-- 
Greg



More information about the Python-list mailing list