#python Str.format method is used to format the output of a string.
# ". Format ()
Print (' {0}+{1}={2} '. Format (+/-))
#1 +2=3 The numbers in curly braces in the visible string correspond to several parameters of format.
Print (' {}+{}={} '. Format (+/-))
#1 +2=3 If you omit a number, you can get the same output. But the replacement order by default follows [0],[1],[2] ... For
#
Print (' {1}+{0}={2} '. Format (+/-))
#2 +1=3 If you replace {0} and {1}, the result is the same.
Print (' {0}\tlove\t{1} '. Format (' I ', ' you! '))
#I Love ! output string
Name= ' Xiaoming '
Age=23
Print (' {0}\tis\t{1}\tyears old this year! '). Format (name,age))
#xiaoming is at years old!
Print (' {0:.4} '. Format (1/6))
#0.1667 decimal point precision matched to 4 bits
Print (' {0:8}:{1:8} '. Format (' name ', ' Xiaoming '))
#name : xiaoming width configuration
#
Print (' {0:<7.3} ... '. Format (1/3))
#0.333. #精宽度控制 (width left), the same as ' > ' for the right, ' ^ ' is centered. The symbol is very image.
The
#python Str.format method is used for formatted output of strings.