我有json数据,它以格式存储:
[{"Status": "status", "Command": "command", "IPAddress": "xx.xx.xx.xx ", "name": "name", "Service": "service"}]
我们将进一步修改以获得:
"Status="status","Command="command","IPAddress="xx.xx.xx.xx","name="name","Service="service"
但是我希望使用python脚本从键中删除双引号(")。所期望的输出如下:
Status="status",Command="command",IPAddress="xx.xx.xx.xx",name="name",Service="service"
我仍然是python的新手,非常感谢您对此有任何帮助
答案 0 :(得分:1)
使用简单的迭代。
<强>实施例强>
j = [{"Status": "status", "Command": "command", "IPAddress": "xx.xx.xx.xx ", "name": "name", "Service": "service"}]
s = ""
for k,v in j[0].items():
s += '{0}: "{1}", '.format(k, v)
print(s.rstrip(", "))
<强>输出:强>
Status: "status", IPAddress: "xx.xx.xx.xx ", Command: "command", name: "name", Service: "service"