[英]ValueError: zero length field name in format with read and write
Does anybody know if it is possible to avoid the error ValueError: zero length field
reading/writing from/to a file with Python 2.6.6 as specified in the following: 有人知道是否有可能避免错误ValueError: zero length field
读/写,使用Python 2.6.6,如下所述:
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
Change 更改
"{:<{width}}".format(col, width=widths[index])
into 进入
"{0:<{1}}".format(col, widths[index])
Coz in older release of python, you need to point out the order of multiple format field. Coz在旧版本的python中,您需要指出多种格式字段的顺序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.