TypeError: coercing to Unicode: need string or buffer, list found

前端 未结 2 1037
谎友^
谎友^ 2020-12-06 10:44

I\'m trying to get a data parsing script up and running. It works as far as the data manipulation is concerned. What I\'m trying to do is set this up so I can enter multiple

2条回答
  •  孤城傲影
    2020-12-06 11:44

    If you specify an nargs argument to .add_argument, the argument will always be returned as a list.

    Assuming you want to deal with all of the files specified, loop through that list:

    for filename in args.infile:
        for line in csv.reader(open(filename)): 
            for item in line[2:]:
    
                #to skip empty cells
    [...]
    

    Or if you really just want to be able to specify a single file; just get rid of nargs="+".

提交回复
热议问题