如何在immut中使用相同的键获取所有值.字典? [英] How to get all values with the same key in an immut. dict?

查看:192
本文介绍了如何在immut中使用相同的键获取所有值.字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ImmutableMultiDict([('course', u'2132'), ('course', u'2121'), 
('myc', u''), ('ok', u'Add to my plan')])

是我用Python编写的WSGI代码中的字典.

is the dict I get in my WSGI-Code written in Python.

现在,我想使用course键获取所有条目,但是args.get("course")仅返回2132的第一个值.

Now I want to get all entries with the course key, but args.get("course") only returns the first value of 2132.

推荐答案

您可以使用 getlist 方法,就像这样

You can use getlist method, like this

immutable_dict_obj.getlist("course")

这将返回与键course相对应的值的列表.

This will return a list of values corresponding to the key course.

这篇关于如何在immut中使用相同的键获取所有值.字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆