python 2.7 quick reference : string.format
Je cherchais depuis longtemps une page qui détaille "".format() en python... quelques exemples :
>>> "{:05d}".format(36)
'00036'
>>> "{:4x}".format(255)
' ff'
>>> "{:#4x}".format(255)
'0xff'
>>> "{:b}".format(9)
'1001'
>>> "{:08b}".format(9)
'00001001'
>>> "{:c}".format(97)
'a'
>>> "{:d}".format(0xff)
'255'
>>> "{:x}".format(105199)
'19aef'
>>> "{:X}".format(105199)
'19AEF'
>>> "{:<#9X}".format(105199)
'0X19AEF '
permalink -
-
http://infohost.nmt.edu/tcc/help/pubs/python/web/format-spec.html