python中判断json的key是否存在,以及动态获取key和value
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json

·
import json
body={'discountPrice':{'1':'5.4847','59':'5.1938','100':'4.9030'}}
#将dict类型的数据转换成str
jsDumps=json.dumps(body)
jsLoads = json.loads(jsDumps)
if ('discountPrice' in jsLoads) :
print('存在')
else:
print('不存在')
#循环获取key和value
for r in jsLoads['discountPrice']:
print(f'qty:{r} price{jsLoads["discountPrice"][r]}')




适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
68c25aec
* :memo: update customers
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :memo: add badge to Cloudback
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
---------
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 4 天前
ac0133ea
Bumps [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin) from 1.4.5 to 1.4.6.
- [Release notes](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/releases)
- [Commits](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/compare/v1.4.5...v1.4.6)
---
updated-dependencies:
- dependency-name: mkdocs-git-revision-date-localized-plugin
dependency-version: 1.4.6
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 5 天前
更多推荐
所有评论(0)