ValueError: not enough values to unpack (expected 11, got 1)

前端 未结 3 905
执笔经年
执笔经年 2021-01-04 19:14

I wrote a script for system automation, but I\'m getting the error described in the title. My code below is the relevant portion of the script. What is the problem?

3条回答
  •  独厮守ぢ
    2021-01-04 19:29

    The error message is fairly self-explanatory

    (a,b,c,d,e) = line.split()
    

    expects line.split() to yield 5 elements, but in your case, it is only yielding 1 element. This could be because the data is not in the format you expect, a rogue malformed line, or maybe an empty line - there's no way to know.

    To see what line is causing the issue, you could add some debug statements like this:

    if len(line.split()) != 11:
        print line
    

    As Martin suggests, you might also be splitting on the wrong delimiter.

提交回复
热议问题