Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python和don'中引用嵌套字典;I don’我不知道怎么做,请有人解释一下_Python_Json_Dictionary_Nested_Urllib - Fatal编程技术网

如何在Python和don'中引用嵌套字典;I don’我不知道怎么做,请有人解释一下

如何在Python和don'中引用嵌套字典;I don’我不知道怎么做,请有人解释一下,python,json,dictionary,nested,urllib,Python,Json,Dictionary,Nested,Urllib,所以我使用了一个相当大的API来创建一个discord机器人。由于嵌套字典,我在从API中获取所需信息时遇到了一些问题。我将api制作成json,并将其用作我的字典。我可以称之为状态很好,因为它在树的顶端,但当我要从树上下来时,我完全迷失了方向。请帮忙 这是我的密码: 导入URL库 从urllib.request将urlopen导入为open 导入json url='1〕https://fortnite-api.com/v2/shop/br/combined' #打开url json_obj=

所以我使用了一个相当大的API来创建一个discord机器人。由于嵌套字典,我在从API中获取所需信息时遇到了一些问题。我将api制作成json,并将其用作我的字典。我可以称之为状态很好,因为它在树的顶端,但当我要从树上下来时,我完全迷失了方向。请帮忙

这是我的密码:


导入URL库
从urllib.request将urlopen导入为open
导入json
url='1〕https://fortnite-api.com/v2/shop/br/combined'
#打开url
json_obj=open(url)
#保存到json
json_data=json.load(json_obj)
#打印URL
打印(url)
###字典的变量
json_status=json_数据['status']
#打印API状态,200已连接
打印('API状态:'+str(json_状态))
#下了树,我迷路了
json_name=json_data['data']['featured']['entries']['items']['name']
打印(json_名称)
json树位于该链接的“BR Shop Combined”下。只需点击回复。打字太复杂了

以下是json: {“状态”:200,“数据”:{“哈希”:“aefe4148418f3406bfd155349369360c70e13534”,“日期”:“2020-07-10T00:00:00Z”,“特色”:{“名称”:“特色”,“条目”: [{“regularPrice”:2000,“finalPrice”:2000,“bundle”:null,“banner”:{“value”:“Selectable Styles!”,“backendValue”:“Selectable Styles”},“giftable”:true,“Returnable”:true,“sortPriority”:-11,“categories”:[“Panel 3”],“devName”:“[VIRTUAL]1 x Moisty Merman,1 x Mertank for 2000 MtxCurrency”,“offerId”:“v2:/ecbc2dd0399e9510014273e231bf6b1ae6cd0caeb3d1da754a0715a5561f6e3”,“显示资产路径”:“fornitegame/Content/Catalog/displaysets/DA_Featured_CID_130_Athena_Commando_M_Merman”,“物品”:[{“id”:“CID_130_Athena_Commando_M_Merman”,“姓名”:“Moisty Merman”,“描述”:“从……工作室B的后台深处”:“类型”:“装备”;“value”和“{”displayValue:“装备”、“后端价值”:“AthenaCharacter”},“稀有性”:{“价值”:“传奇性”、“displayValue”:“传奇性”、“后端价值”:“EFortRarity::传奇性”},“系列”:null,“设置”:null,“简介”:{“章节”:“1”,“季节”:“4”,“文本”:“在第1章中介绍,第4季”。“后端价值”:“4},“图像”:{“smallIcon”:”https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/smallicon.png,“图标”:https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/icon.png,“特色”:https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/featured.png,“其他”:null},“变体”:[{“通道”:“材料”,“类型”:”颜色“,”选项“:[{”标记“:”Mat1“,”名称“:”默认值“,”图像“:”https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/variants/material/mat1.png},{“标记”:“Mat2”,“名称”:“蓝色”,“图像”:https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/variants/material/mat2.png},{“标记”:“Mat3”,“名称”:“橙色”,“图像”:https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/variants/material/mat3.png},{“tag”:“Mat4”,“name”:“PURPLE”,“image”:https://fortnite-api.com/images/cosmetics/br/cid_130_athena_commando_m_merman/variants/material/mat4.png“}]}],“gameplayTags”:[“Cosmetics.Source.ItemShop”,“Cosmetics.UserFacingFlags.HasVariants”化妆品。过滤器。第4季“],“展示视频”:“TGD91vW8vnw”,“displayAssetPath”:“FortniteGame/Content/Catalog/DisplayAssets/DA_Featured_CID_130_Athena_Commando_M_Merman”,“定义路径”:“FortniteGame/Content/Athena/Heroes/HID_130_Athena_Commando__Merman”,“路径”:“FortniteGame/Content/Athena/Items/Cosmatics/Characters/CID_Athena_130_Commando_M_Merman”“添加”的“补充”中,“添加”的“添加”的“添加”的“添加”的“添加”的“添加”的“添加”的“2019-11-11-20-10-05-05-05-25-20-20-11-20-11-20-11-20-11-20-20-12-20:12:20 20 20 20 20:50:50:00:24Z”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史”,“商店历史历史”,“商店历史历史历史”,“2018-2018-2018-2018-05-05-05-05-05-05-05-05-05-05-05-05-05-05-50-25-25-25-25-25-25-25-25-25-25-50-25-25-50-50-50-50-50-50-50-50-50-50-20 00 00 00 00 00 00“,“2020-06-05T00:00:00Z”,“2020-07-10T00:00:00Z”],{“id”:“BID_051_Merman”,“名称”:“Mertank”,“描述”:“呼吸轻松”,“类型”:{“值”:“背包”,“显示值”:“背面闪光”,“背面闪光”,“背面闪光”:“AthenaBackpack”},“稀有性”:{“值”:“传奇性”,“显示值”:“传奇性”,“背面闪光”:“传奇性”:“背面闪光”,“背面闪光”,“系列”:“null”,“引言”:{”章节“:“1”,“季节“:“4”,“文本“:“在第1章中介绍,第4季。”,“backendValue”:4},“图像”:{“smallIcon”:”https://fortnite-api.com/images/cosmetics/br/bid_051_merman/smallicon.png,“图标”:https://fortnite-api.com/images/cosmetics/br/bid_051_merman/icon.png,“特色”:null,“其他”:null},“变体”:null,“游戏标签”:[“化妆品.Source.ItemShop“,”化妆品.Filter.Season.4“,”showcaseVideo“:”enU9gwEHRm8“,”displayAssetPath“:”null,“定义路径“:”null,“路径“:”FortniteGame/Content/Athena/Items/Cosmetics/Backpacks/BID_051_Merman“,”添加“:”2019-11-20T12:50:40Z“,”shopHistory“:”[“2020-06-05T00:00:00Z”,“2020-07-10T00:00:00Z”],”2000,“最终价格“,”2000,”bundle:null,“banner”:{“value”:“PickaxeIncluded!”,“backendValue”:“PickaxeIncluded”},“giftable”:true,“retailable”:true,“sortPriority”:-1,“categority”:[“Panel 1”],“devName”:“[虚拟]1个美国队长,1个原始金刚盾,1个2000 MtxCurrency的原始金刚盾”,“offerId”:”v2:/5C87C543D74FFA7E0205837908F5285AFE87A1540C94BF9E5B2157FC0640B,“显示资产路径”:“fornitegame/Content/Catalog/DisplayAssets/DA_characterized_CID_807_Athena_Commando_CandyApple_B1U7X”,“项目”:[{“id”:“CID_807_Athena_Commando_M_CandyApple_B1U7X”,“姓名”:“美国队长”,“描述”:”超级战士史蒂夫·罗杰斯是自由的永恒哨兵。“,”类型“:{“价值”:“装备”,“显示价值”:“装备”,“后端价值”:“AthenaCharacter”},“稀有性”:{“价值”:“惊奇”,“显示价值”:“惊奇系列”,“后端价值”:“EFortRarity::Epic”},“系列”:{“价值”:“惊奇系列”,“图像”:null,“后端价值”:“惊奇系列”},“设置”:{“价值”:”复仇者”,“文本”:“复仇者集的一部分”。,“后端值”:
import requests


url = "https://fortnite-api.com/v2/shop/br/combined"

response = requests.get(url)
response.raise_for_status()

entries = response.json()["data"]["featured"]["entries"]

for entry in entries:
    for item in entry["items"]:
        print(item)
    print()