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

前端 未结 3 911
执笔经年
执笔经年 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:42

    For the line

    line.split()
    

    What are you splitting on? Looks like a CSV, so try

    line.split(',')
    

    Example:

    "one,two,three".split()  # returns one element ["one,two,three"]
    "one,two,three".split(',')  # returns three elements ["one", "two", "three"]
    

    As @TigerhawkT3 mentions, it would be better to use the CSV module. Incredibly quick and easy method available here.

提交回复
热议问题