美文网首页
使用python核对json格式的属性

使用python核对json格式的属性

作者: byhbc | 来源:发表于2021-07-23 09:52 被阅读0次

在测试的时候,核对json格式,使用python挺方便的

代码如下:

```

#coding=utf-8

importjson

defmain():

s=input('请输入json文档,并且回车键继续')

data=json.loads(s)

print(data)

non_str=[]

#查找的关键字

str=[''os','os_2']

foriinrange(0,len(str)):

print(str[i],':',str[i]indata,':',data.get(str[i]))

if(str[i]indata) ==False:

non_str.append(str[i])

print('--------------------------------')

print('err:',non_str)

if__name__ =='__main__':

while1==1:

main()

```

相关文章

网友评论

      本文标题:使用python核对json格式的属性

      本文链接:https://www.haomeiwen.com/subject/wyovyxtx.html