-2
我的词典列表:更新列表
my_list = [{'question_text': 'question text'}, {'question_text': 'question text'}]
我需要更新my_list
所以它看起来像:
my_list = [{'question_text': 'question text', 'answer_text': 'answer text'},
{'question_text': 'question text', 'answer_text': 'answer text'}]
我需要做my_list
在for循环中更新,因为answer_text
的数据来自其他列表。
编辑: 我可以改变我初始化my_list
的方式,通过将一个空的刺痛作为价值answer_text
my_list = [{'question_text': 'question text', 'answer_text': ''},
{'question_text': 'question text', 'answer_text': ''}]
这样的清单应最初由“问题”/“答案”对组成,以设置正确的关系 – RomanPerekhrest
到目前为止,这么好。你有什么问题? – Holloway
你在问怎么把东西附加到列表中? – doctorlove