# tpl='i am {},age{},{}'.format('火虎',32,'alex')
# print(tpl)
# 输出:i am 火虎,age32,alex 不一一对应则报错
# tpl='i am {1},age{2},{0}'.format('火虎',32,'alex')
# print(tpl)
# 输出:i am 32,agealex,火虎 看看明白
# tpl='i am {2},age{2},'.format('火虎',32,'alex')
# print(tpl)
# 输出:i am alex,agealex.
# tpl='i am {2},age{2},'.format('火虎')
# print(tpl)
# 报错原因是前面2对应后面没有值,那么将2换做0即可
# 字典的形式
# tpl='i am {name},age{age},really{name}'.format(name='火虎',age=32,)
# tpl='i am {name},age{age},really{name}'.format(**{'name':'火虎','age':32})
#
#
# a={'name':'火虎','age':32}
# tpl='i am {name},age{age},really{name}'.format(**a) #字典 两种方式
#
# print(tpl)
# 输出:i am 火虎,age32,really火虎
# ==============================================================================
# tpl='i am {1[0]},age{0[2]},really{1[1]}'.format([1,2,3],[4,5,6])
# print(tpl)
# 输出:i am 4,age3,really5
# tpl='我叫{:s},今年{:d},考试得分{:f}'.format('火虎',18,98.23)
# print(tpl)
# 输出:我叫火虎,今年18,考试得分98.230000
# l=['火虎',18,98.123]
# tpl='我叫{:s},今年{:d},考试得分{:f}'.format(*l)
# print(tpl)
# 同上
#=============================================================================================
tpl='numbers{:b},{:0},{:d},{:x},{:X},{:%}'.format(15,15,15,15,15,15.87)#b:转换成二进制,0:转换成八进制,d:转换成十进制,
# x转换成十六进制(小写)X转换成十六进制(大写)%:就是百分号默认小数点后6位
print(tpl)
#输出:numbers1111,15,15,f,F,1587.000000%