IndexError: list index out of range reading/writing from/to file

前端 未结 3 486
悲&欢浪女
悲&欢浪女 2021-01-27 09:13

I have got this script on Python 2.6 with RHEL OS:

import csv

def write_cols(data):
    col_spacer = \"   \"      # added between columns
    widths = [0] * len         


        
3条回答
  •  深忆病人
    2021-01-27 09:35

    You need to change this

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

    to this

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

    and it will work.

提交回复
热议问题