Home > other >  About the format with the output of the floating point Numbers for width of two kinds of different s
About the format with the output of the floating point Numbers for width of two kinds of different s

Time:12-29

Manual mentioned in the format "width is a definition of the minimum field width of decimal int
"But if we use float? Also can be tried, but there will be two different cases, 6, 7 lines of code to run with one line of code to run, but in three or four line of the output @ how disappeared,
So what the reasons for this difference is?
 print (" {0:=^ 5} ". The format (' @ ')) # normal 

Print (" {0:=^ 5.0} ". The format (' @ ')) # after floating point Numbers are all 0
the condition of thePrint (" {0:=^ 5.00} ". The format (' @ '))

Print (" {0:=^ 5.01} ". The format (' @ ')) not all # after floating point Numbers 0
the condition of thePrint (" {0:=^ 5.1} ". The format (' @ '))
Output:
==@==
=====
=====
==@==
==@==
  • Related