# 元组传值
print('my name is {}, age is {}'.format('lala',22))
# 列表传值
li = ['chenpeng',22]
print('my name is {}, age is {}'.format(*li))
# 字典传值
hash = {'name':'chenpeng', 'age':20}
print('my name is {name}, age is {age}'.format(**hash))
# 元组传值
print('my name is {}, age is {}'.format('lala',22))
# 列表传值
li = ['chenpeng',22]
print('my name is {}, age is {}'.format(*li))
# 字典传值
hash = {'name':'chenpeng', 'age':20}
print('my name is {name}, age is {age}'.format(**hash))
本文标题:{},.format()用法
本文链接:https://www.haomeiwen.com/subject/adkrcqtx.html
网友评论