【发布时间】:2014-11-04 20:18:35
【问题描述】:
我有一个字典列表。有时,我想更改并保存其中一个字典,以便在重新启动脚本时使用新消息。现在,我通过修改脚本并重新运行它来进行更改。我想将其从脚本中提取出来,并将字典列表放入某种配置文件中。
我找到了有关如何将列表写入file 的答案,但这假设它是一个平面列表。如何使用字典列表来做到这一点?
我的列表如下所示:
logic_steps = [
{
'pattern': "asdfghjkl",
'message': "This is not possible"
},
{
'pattern': "anotherpatterntomatch",
'message': "The parameter provided application is invalid"
},
{
'pattern': "athirdpatterntomatch",
'message': "Expected value for debugging"
},
]
【问题讨论】:
标签: python list file dictionary