我有两个python列表:
cols = ['InfoKey', 'InfoData']
以及
vals = ['Row 1: [LANGUAGE SUPPORT MODE, Standard]', 'Row 2: [RELEASE, 15.00.04.01]', 'Row 3: [VERSION, 15.00.04.01]']
如何合并它们并返回JSON类型:
{
"data": [{
"Infokey": "LANGUAGE SUPPORT MODE",
"InfoData": "Standard"
},
{
"Infokey": "RELEASE",
"InfoData": "15.00 .04 .01"
},
{
"Infokey": "VERSION",
"InfoData": "15.00 .04 .01"
}
]
}
您可以在这里使用
regex
来提取[...]
之间的字符串。下面是示例:PS:您需要将我在控制台上打印的输出存储到
dict
,并将每个dict对象附加到列表中。我把它留给你去做。这个呢:
结果:
正如@PM所说,这在很大程度上取决于所描述的数据格式。你知道吗
相关问题 更多 >
编程相关推荐