I have a JSON file as follows namerunoob alexa10000 sites site1wwwrunoobcom site2mrunoobcom site3crunoobcom How should I query the value of site2 in Python
You can use the json module in Python to load the JSON file and access the value of "site2" as follows:
import json
# load the JSON file
with open('file.json') as f:
data = json.load(f)
# access the value of "site2"
site2 = data['sites']['site2']
print(site2) # output: "m.runoob.com"
原文地址: https://www.cveoy.top/t/topic/fXVL 著作权归作者所有。请勿转载和采集!