def get_dict_leaves_count(dic):
if len(dic) == 0:
return 0
else:
cnt = 0
for k, v in dic.items():
if not isinstance(v, Mapping):
cnt += 1
else:
cnt += get_dict_leaves_count(v)
return cnt
标签:count,cnt,return,get,Python,leaves,dic
来源: https://www.cnblogs.com/zhangzhihui/p/15837976.html