1.format() 字典方式

test = 'I am {name},age{a}'
#v = test.format(name = 'alex',a =19)
v = test.format(**{"name" : 'alex',"a":19})
print(v)


_____________________________
I am alex,age19

2. 

test = 'I am {0},age{0}'
# v = test.format(name = 'alex',a =19)
#v = test.format(**{"name" : 'alex',"a":19})
v = test.format('alex',19)

print(v)

————————————
I am alex,age 19

  

posted on 2019-01-30 11:29  大叔学AI  阅读(95)  评论(0编辑  收藏  举报