1、
format位置参数
>>> "{0},{1},{2}".format("aaa","bbb","ccc")
'aaa,bbb,ccc'
>>> "{2},{1},{0}".format("aaa","bbb","ccc")
'ccc,bbb,aaa'
>>> "{0},{2},{1}".format("aaa","bbb","ccc")
'aaa,ccc,bbb'
format关键字参数
>>> "{a},{b},{c}".format(a = "aaa",b = "bbb",c = "ccc")
'aaa,bbb,ccc'
>>> "{a},{b},{c}".format(a = "mmm",b = "nnn",c = "aaa")
'mmm,nnn,aaa'
位置参数和关键字参数:
>>> "{0},{x},{y}".format("mmm",x = "0000",y = "1111")
'mmm,0000,1111'
>>> "{0},{1:.2f}".format("test",83.23214231)
'test,83.23'