一般格式:
' text content {} text '.format( to be shown in {})
{}是format格式的占位符,可以多个,并在format中按顺序指定参数,如:
'text{}text{}text'.format(a,b)
print后的结果为:text a text b
再如:
dict={'key1':1,'key2':2}
for k,v in dict.items():
print('字典dict中的键{}对应的值是{}'.format(k,v))
结果为:字典dict中的键key1对应的值是1