1. 程式人生 > >python ValueError: cannot switch from automatic field numbering to manual field specification

python ValueError: cannot switch from automatic field numbering to manual field specification

ValueError: cannot switch from automatic field numbering to manual field specification

此問題是format()函式 前面大括號裡 沒寫 數字 對應後面的 ()的順序的值

tplt="{:^10}\t{:{3}^8}\t{:^10}"
    print(tplt.format("排名","學校","總分",chr(12288)))

錯誤
tplt="{0:^10}\t{1:{3}^8}\t{2:^10}"
    print(tplt.format("排名","學校","總分",chr(12288)))

正確