我有一个字典列表。偶尔,我想更改并保存其中一个字典,以便在重新启动脚本时使用新的消息。目前,我通过修改脚本并重新运行来进行更改。我想将这个过程从脚本中分离出来,并将字典列表放入某种配置文件中。
我找到了如何将列表写入文件的答案,但这假定它是一个扁平的列表。我如何处理一个字典列表?
我的列表长这样:
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"
},
]