{},.format()用法

# 元组传值
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()用法)