我正在尝试将两个list[dict]
合并为以下格式,并对这两种技术和子技术进行排序,但我不确定如何在不影响其他技术的情况下正确地连接它们
techniques = [{
"technique_id":"T1548",
"technique":"demo",
"url":"url",
"tactic":[
"demo",
"demo"
]
}]
subtechniques = [{
"technique_id":"T1548.002",
"technique":"demo",
"url":"url"
}]
def merge_techniques(techniques, subtechniques):
change_list = []
for x in techniques:
for y in subtechniques:
if x['technique_id'] == y['technique_id'].split('.')[0]:
print(x)
print(y)
return change_list
merge_techniques(techniques, subtechniques)
{
"technique_id":"T1548",
"technique":"dmep",
"url":"https://xxxxxxxxxxxx",
"tactic":[
"xxxxxxxxxxxx",
"xxxxxxxxxxxx"
],
"subtechnique": [
{
"technique_id":"T1548.002",
"technique":"demo",
"url":"url"
}
]
}
如果不想创建新对象,可以放弃复制操作
相关问题 更多 >
编程相关推荐