python .format IndexError: tuple index out of range

 這樣寫,沒有問題

x1=1
x2=2
y1=3
y2=4
c='xx{}xx{}xx{}xx{}'.format(x1,y1,x2,y2)
print(c)

 但是在format中引用就是報錯

x1=1
x2=2
y1=3
y2=4
c='xx{}xx{}xx{}xx{}'.format(x1,y1,x2,yy2=y2)
print(c)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章