【发布时间】:2022-01-12 19:28:44
【问题描述】:
如果我有字典:
d = {0:'Fred', 1:'Fred', 2:'Zippy', 3:'Bob'}
我怎样才能知道"Fred"在其中出现了多少次?
【问题讨论】:
标签: python dictionary key
如果我有字典:
d = {0:'Fred', 1:'Fred', 2:'Zippy', 3:'Bob'}
我怎样才能知道"Fred"在其中出现了多少次?
【问题讨论】:
标签: python dictionary key
你可以这样做:
c=0
for i in d.values():
if i=='Fred':
c+=1
print(c)
【讨论】: