ValueError: need more than 1 value to unpack

后端 未结 1 1012
说谎
说谎 2020-12-06 23:35

Ok, i know this topic has been addressed several times, but none of what i seen is helping me. I\'m getting the error in the title and i\'m not sure how to fix the error. He

相关标签:
1条回答
  • 2020-12-06 23:58

    You probably have at least one empty line in your file (usually the last line); explicitly test for that:

    for record in students:
        if not record.strip():
            continue
        n, ex1, ex2, ex3 = record.split(",")
    

    You may want to look at the csv module to read your student records with instead; you'd still need to skip empty lines but the comma-splitting is handled for you.

    0 讨论(0)
提交回复
热议问题