This article summarizes some simple basic output format form, the following words do not say more, to see the detailed introduction bar.
A, print string
>>> print "I ' m%s"% ("Jihite")
I ' m jihite
Second, print integer
>>> print "I ' m%d years old" (%)
i ' M years old
Third, printing floating point numbers
>>> print "π=%f"% (3.1415926)
π=3.141593
Printing floating-point numbers (specify how many decimal places to keep)
>>> print "π=%.3f"% (3.1415926)
π=3.142
V. Specify the placeholder width
>>> print "name:%8s age:%8d weight:%8.2f"% ("Jihite", 62.2) Name:jihite age
: WEIGHT: 62. 20
Six, specify the placeholder width (left-aligned)
>>> print "name:%-8s age:%-8d weight:%-8.2f"% ("Jihite", 62.2) name:jihite age:17
Vii. specify placeholders (only 0 placeholders)
>>> print "name:%-8s age:%08d weight:%08.2f"% ("Jihite", 62.2) name:jihite age:00000017 0062.20
Viii. Scientific Counting method
>>> format (0.0000023, '. 2e ')
' 2.30e-06 '
>>> format (0.23, '. 2e ')
' 2.30e-01 '
Summarize
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.