我在python脚本中有以下几行代码,执行后我总是会收到错误消息:
“ ValueError:格式的零长度字段名称”
对于包含.format(...)命令的每行。
# Construct info table (debugging)
table = []
align = "{:>6} {:^10} {:>10} {:>10} {:>10} {:^3} {:<10}"
header = align.format("#", "xLow", "x", "xUp", "Purity", "+/-", "Error") #Purity = 1-EWK/Data
hLine = "="*70
table.append("")
table.append(hLine)
table.append("{:^70}".format("TGraph"))
table.append(header)
table.append(hLine)
# For-loop: All values x-y and their errors
for i, xV in enumerate(x, 0):
row = align.format(i+1, "%.2f" % xerrl[i], "%.2f" % x[i], "%.2f" % xerrh[i], "%.3f" % y[i], "+/-", "%.3f" % yerrh[i])
table.append(row)
table.append(hLine)
我做错什么了吗?我想念什么?
最好的问候, 码头