You can use the following code to get the location of "site2" in the JSON object:

location = myObj["sites"].keys().index("site2")

This will give you the index value of "site2" in the "sites" dictionary, which is 1. You can then use this index value to look up the value of "site2" in the dictionary:

value = myObj["sites"].values()[location]

This will give you the value "m.runoob.com".

I have a JSON as followsmyObj = name runoob alexa10000 sites site1 wwwrunoobcom site2 mrunoobcom site3 crunoobcom Now I know the value of site2 is mrunoobcom How can

原文地址: https://www.cveoy.top/t/topic/fYxL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录