谁能解释下X这串代码 小甲鱼找猪队友那题
本帖最后由 Angelina_Jolie 于 2021-11-8 17:45 编辑members = {
"鱼C工作室" : {"小甲鱼":83, "不二如是":89, "二师兄":64, "小师妹":75, "鱼小二":96},
"复仇者联盟" : {"钢铁侠":85, "绿巨人":39, "黑寡妇":82, "鹰眼":73, "雷神":99},
"奥特曼家族" : {"迪迦":99, "艾斯":84, "泰罗":63, "佐菲":78, "赛文":78}}
x = , key=members.get) for o in members]
https://fishc.com.cn/thread-204931-1-1.html members = {
"鱼C工作室" : {"小甲鱼":83, "不二如是":89, "二师兄":64, "小师妹":75, "鱼小二":96},
"复仇者联盟" : {"钢铁侠":85, "绿巨人":39, "黑寡妇":82, "鹰眼":73, "雷神":99},
"奥特曼家族" : {"迪迦":99, "艾斯":84, "泰罗":63, "佐菲":78, "赛文":78}}
x = , key=members.get) for o in members]
# 通过for循环创建一个数组
# a+b+c 这是简单的字符串合并
# min(a, key=b)找到a中b值最小的
# members.get 获取字典的value
# 所以min(members, key=members.get)就是将字典的value进行排序,并返回value最小的key
# 比如"鱼C工作室" 中“二师兄”的value最小,“二师兄”作为字典的key被返回
页:
[1]