我对python是完全陌生的,并且一直在研究一些需要阅读一些类似这样的复杂字典的东西。你知道吗
var_data:
{
'pvc' : {
'files' : ['logs1.txt', 'logs2.txt']
'version' : 'v192.2'
},
'mci' : {
'files' : ['ld33r3.txt', 'rkkk3k3.txt']
'version' : 'v39.2'
},
'dac' : {
'files' : ['33.txt', 'logfile3.txt']
'version' : 'v32.2'
}
}
我绞尽脑汁想弄明白这是怎么回事。 基本上,我的代码应该能够有一个if条件,它将查看这些数据并根据上面的值为“文件”执行特定的条件语句。。 例如 'dac':{
非常感谢您的指导。。。你知道吗
干杯 卡比尔
听起来像是在问如何从字典中提取键值对。iteritems()可能是语法上最紧凑的方法。举个例子:
不确定,除非你用我在评论中写的内容更新你的问题,我想这就是你想要的?:-
而且,你的字典结构不好。在
files
键值的末尾缺少逗号。而var_data:
是错误的。你知道吗您有一个包含3个字典的字典,每个字典包含一个字符串列表和一个字符串。你知道吗
你可以在上面循环:
相关问题 更多 >
编程相关推荐