请修改上面的代码,以适配下面的json : {"name":"xjs1","url":"www.baidu.com","data":{"cat":"kangsf","hw":[{"code":"wh","dealtime":"2022-05-11 22:01:49"},{"code":"hg","dealtime":"2022-05-11 22:01:49"}]}}
时间: 2023-06-15 18:07:13 浏览: 172
以下是修改后的代码:
```python
import json
json_string = '{"name":"xjs1","url":"www.baidu.com","data":{"cat":"kangsf","hw":[{"code":"wh","dealtime":"2022-05-11 22:01:49"},{"code":"hg","dealtime":"2022-05-11 22:01:49"}]}}'
data = json.loads(json_string)
print("Name:", data["name"])
print("URL:", data["url"])
print("Category:", data["data"]["cat"])
print("Hardware:")
for hw in data["data"]["hw"]:
print(" Code:", hw["code"])
print(" Deal Time:", hw["dealtime"])
```
输出结果:
```
Name: xjs1
URL: www.baidu.com
Category: kangsf
Hardware:
Code: wh
Deal Time: 2022-05-11 22:01:49
Code: hg
Deal Time: 2022-05-11 22:01:49
```
阅读全文