【发布时间】:2023-01-20 23:17:38
【问题描述】:
所以我有一个这样的命令:
{
"channel_list" : [
{
"channel_index" : 0,
"channel_sth" : "A",
},
{
"channel_index" : 1,
"channel_sth" : "B",
}]
}
我想计算“频道索引”在该字典中出现的频率。 怎么做?
【问题讨论】:
-
根据你的字典有多深,你可以这样做:
Counter(flattened_dict.keys())[channel_index] -
抱歉,它对我不起作用 AttributeError: 'list' object has no attribute 'keys'
标签: python dictionary count