gpt4 book ai didi

python - 值错误 : zero length field name in format with read and write

转载 作者:太空宇宙 更新时间:2023-11-04 10:29:26 25 4
gpt4 key购买 nike

有谁知道是否有可能避免错误 ValueError: zero length field reading/writing from/to a file with Python 2.6.6 as specified in the following:

 File "format.py", line 26, in <module>
for row in write_cols(rows):
File "format.py", line 19, in write_cols
return [col_spacer.join("{:<{width}}".format(col, width=widths[index]) for index, col in enumerate(row)) for row in data]
File "format.py", line 19, in <genexpr>
return [col_spacer.join("{:<{width}}".format(col, width=widths[index]) for index, col in enumerate(row)) for row in data]
ValueError: zero length field name in format

最佳答案

改变

"{:<{width}}".format(col, width=widths[index])

进入

"{0:<{1}}".format(col, widths[index])

因为在旧版本的 python 中,您需要指出多个格式字段的顺序。

关于python - 值错误 : zero length field name in format with read and write,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40587912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com