
1个回答
展开全部
dict使用items()遍历字典的方法(python3是items(),python2是iteritems())。
dict1 = {'a': 2, 'b': 3, 'c': 2 }
def dict(value):
for k, v in dict1.items():
if v == value:
print("{%s: %s}" % (k, v))
dict(2)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询