Django模板字典查找与另一个字典查找值

2024-09-30 08:24:59 发布

您现在位置:Python中文网/ 问答频道 /正文

所以基本上我有一本字典,我们称它为a

a = {1: {'hero': 'Anti-Mage', 'vert': 'http://cdn.dota2.com/apps/dota2/images/heroes/antimage_vert.jpg', 'large': 'http://cdn.dota2.com/apps/dota2/images/heroes/antimage_lg.png'}, 2: ..... , 3: ....  , 96: ....}

我还有一本字典

b = {'playername': 'Mind_Control', 'hero_id': 96, 'player_slot': 4, 'kills': 6, 'deaths': 2, 'assists': 4, 'level': 11}]

我想使用b['hero_id']作为查找,从字典a获取verthero_id对应于字典a中的数字键

所以我试过了

{{a.{b.hero_id}.vert}但什么也没发生。我不知道如何在django模板上搜索这个

{{a.96.vert}}

这给了我我想要的,但这是我手动键入它,这不会工作,因为我做了大量的数据

所以我需要上面的东西


Tags: appscomidhttp字典cdndota2jpg

热门问题