小编use*_*660的帖子

ValueError: 需要 1 个以上的值才能解包,拆分一行

我在同一行有一个包含问题和答案的文件,我想将它们分开并将它们附加到自己的空列表中,但不断收到此错误:
builtins.ValueError: need more than 1 value to unpack

questions_list = []
answers_list = []

questions_file=open('qanda.txt','r')


for line in questions_file:
    line=line.strip()

    questions,answers =line.split(':')

    questions_list.append(questions)
    answers_list.append(answers)
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1