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)))

正确

你可能感兴趣的:(Python学习)