tpl = "i am {},age {},{}".format("server", 18, 'alex')
print(tpl)#传参必须一一对应的关系,否则报错
tpl = "i am {2},age {1},{0}".format("server", 18, 'alex')
print(tpl)#传参必须一一对应的关系,否则报错
tpl = "i am {1},age {1}".format("server", 18, 'alex')
print(tpl)#传参必须一一对应的关系,否则报错
tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%},{}".format(15, 15, 15, 15, 15, 15.87623, 2)
print(tpl)
注 :b2 进制 :o 8进制 :d整形 :x 16进制小写 :X 大写的 :%显示百分比默认为小数点后6位