首页 > 其他分享 >求字典中的最大的值 max(age_counts,key=age_counts.get)

求字典中的最大的值 max(age_counts,key=age_counts.get)

时间:2023-07-05 22:02:40浏览次数:23  
标签:get max age 35 key counts

student_info={
    15:{'jack','rose',},
    18:{'jj'},
    35:{'a','b','c','d'},
}
age_counts = {}# 定义一个字典 key=age   value=name的长度
for age in student_info:

    count = len(student_info[age])
    age_counts[age] = count
    '''
    age_counts={
    15:2,
    18:1,
    35:4,
}
    '''
#计算最大的是哪个age
result=max(age_counts,key=age_counts.get)
print(result)


'''
35
'''

 

标签:get,max,age,35,key,counts
From: https://www.cnblogs.com/haha1988/p/17529907.html

相关文章

  • PHP应用出现500 : The page cannot be displayed because an internal server error h
    问题描述PHP应用突然遇见了500 Thepagecannotbedisplayedbecauseaninternalservererrorhasoccurred.错误,但是如果访问一个静态HTML页面,就可以成功。只要是PHP页面,就是500。 问题解答登录AppService的Kudu站点,查看日志发现一句:  scriptProcessorcouldnotbefoun......
  • 【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed
    问题描述PHP应用突然遇见了500 Thepagecannotbedisplayedbecauseaninternalservererrorhasoccurred.错误,但是如果访问一个静态HTML页面,就可以成功。只要是PHP页面,就是500。 问题解答登录AppService的Kudu站点,查看日志发现一句:  scriptProcessorcouldnotb......
  • pip3 Defaulting to user installation because normal site-packages is not writeab
    Defaultingtouserinstallationbecausenormalsite-packagesisnotwriteable原因:没有操作site-packages目录权限解决方法:命令前加上sudosudopip3installCommandNotFound......
  • Visual Studio2019 BackgoroundImageLayout属性
    ​BackgroundImageLayout属性值背景图片重复:BackgroundImageLayout属性设置为Tile(默认)背景图片左边显示:BackgroundImageLayout属性设置为None背景图片右边显示:BackgroundImageLayout属性设置为None,同时RightToLeft属性设置为Yes背景图片居中显示:BackgroundImageLayout属性设......
  • Spring中getBean方法的使用方法
    在Spring中,可以使用getBean()方法从容器中获取一个已注册的bean实例。以下是getBean()方法的使用方法:使用ApplicationContext获取bean://创建Spring应用上下文ApplicationContextcontext=newClassPathXmlApplicationContext("applicationContext.xml");//通过bean的名......
  • AI Agents:软件2.0雏形与OpenAI的下一步
    本文编译自LilianWeng的个人博客,Lilian现在是OpenAI的HeadofSafetySystems,之前还领导过OpenAI的AppliedAI团队。AIAgent被认为是OpenAI发力的下一个方向。OpenAI的联合创始人AndrejKarpathy在近期的一次公开活动上提到“相比模型训练方法,OpenAI内部目......
  • OSFormer: One-Stage Camouflaged Instance Segmentation with Transformers
    地址:https://arxiv.org/pdf/2207.02255.pdf1.摘要    OSFormer为基于transformer的伪装实例分割(CIS)框架,有两个关键设计,首先是位置敏感transformer(LST),通过【位置引导查询】和【混合卷积前向传播网络】获得定位标签和实例级参数;第二,开发粗糙到精细融合模块(CFF)合并来自LST......
  • ML Agents 学习笔记 (1)
    本文是对https://developer.unity.cn/projects/6232aab0edbc2a0019dcfe38的补充,非原创.0.环境搭建创建虚拟环境,环境内安装ml-agents包等.安装Unity,克隆ML-Agentsgithub仓库至本地.1.打开场景并运行用Unity打开Githubclone下来的项目;具体就是打开Unit......
  • go get -u failed 失败 报错
    panic:internalerror:can'tfindreasonforrequirementongithub.com/pkg/[email protected][running]:cmd/go/internal/modget.(*resolver).updateBuildList.func1({{0x140000ba378,0x15},{0x14000110996,0x6}})/usr/local/go/src/cmd/go/......
  • Java 中使用 OkHttpClent 请求接口 get方式 post方式
    学习记录,不喜勿喷什么是OkHttp一般在Java平台上,我们会使用ApacheHttpClient作为Http客户端,用于发送HTTP请求,并对响应进行处理。比如可以使用http客户端与第三方服务(如SSO服务)进行集成,当然还可以爬取网上的数据等。OKHttp与HttpClient类似,也是一个Http客户端,提供了对HTTP......