【发布时间】:2021-11-21 11:09:12
【问题描述】:
我有以下 JSON,例如:
{
"name": "test",
"version": "0.2.0",
"lock": 1,
"requires": true,
"dependencies": {
"@yamm/double": {
"version": "7.14.5",
"requires": {
"@ginu/highlight": "^7.4.5"
}
},
"@dauh/data": {
"version": "7.15.0",
},
"@babel/core": {
"version": "7.12.3",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.12.3.tgz",
"integrity": "sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g==",
"requires": {
"@babel/traverse": "^7.12.1",
"@babel/types": "^7.12.1",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.1",
"json5": "^2.1.2",
"lodash": "^4.17.19",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
我只想用Python打印requires里面的数据
我正在尝试不同的方法,但它不起作用。请帮忙。我该怎么做?
【问题讨论】:
-
应该是字符串,但不是……就是这样
-
我只想打印里面需要使用 Python 的数据 仅供参考,该 JSON 文档中有 3x
requires。另外,似乎已经是 json,您具体遇到了什么问题?在 Python 中访问字典?阅读docs。 -
有什么不同的方式给你试过了?您使用不同的方式遇到了哪些具体问题? “不工作”不足以描述您的问题。请使用tour、阅读what's on-topic here、How to Ask和question checklist,并提供minimal reproducible example。欢迎使用 Stack Overflow!
标签: python json python-3.x parsing