@format()方法的格式控制
{ <参数序号> : <格式控制标记>}
example1:
“{0:=^20}”.format(“PYTHON”)
‘=PYTHON=’
example2:
“{0:*>20}”.format(“BIT”)
‘*****************BIT’
example3:
“{:10}”.format(“BIT”)
'BIT ’
example4:
“{0:,.2f}”.format(12345.6789)
‘12,345.68’
example5:
“{0:b},{0:c},{0:d},{0:o},{0:x},{0:X}”.format(425)
‘110101001,Ʃ,425,651,1a9,1A9’
example6:
“{0:e},{0:E},{0:f},{0:%}”.format(3.14)
‘3.140000e+00,3.140000E+00,3.140000,314.000000%’
引用自:“Python语言程序设计” 嵩天 、黄天羽 、礼欣