python - 尝试创建表时出现“ValueError:格式中的零长度字段名称”
问题描述
我在 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)
难道我做错了什么?我错过了什么?
最好的问候, 玛丽娜
解决方案
推荐阅读
- flutter - 使用颤振 lint 后,TODO 注释不会出现在问题中作为 VS Code 的警告
- python - Python Pandas 样式突出显示具有不同条件的每一列的特定单元格
- azure-cosmosdb-sqlapi - 在 Cosmos db sql api 中的文档中添加键
- tableau-api - Tableau:计算字段(获取第 n 个订单的日期)
- c# - 将 DateTimeOffset 与夏令时进行比较
- javascript - 根据条件提取和添加标签
- python - pyinstaller 在形成 python exe 时出错
- javascript - 如果函数参数可能是两种不同的类型,如何解决 TypeScript 错误?
- linux - 如何验证 USB 串行选项驱动程序是否适用于 arm-linux 板?
- java - Spark 中的 ClassCastException 读取 Teradata 和写入 Parquet