社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Mateen Ulhaq

Mateen Ulhaq 最近创建的主题
Mateen Ulhaq 最近回复了
3 年前
回复了 Mateen Ulhaq 创建的主题 » Python 3中的字典和循环。十、

这就是一个人如何找到最好的学生:

def by_total_grade(name):
    return sum(grades[name])

best_student = max(grades, key=by_total_grade)

完整示例:

grades = {
    "Alex": [3, 7, 11, 10, 8],
    "Ben": [6, 12, 4, 9, 9],
    "Сarla": [5, 10, 7, 5, 9],
}

best_student = max(grades, key=lambda k: sum(grades[k]))
best_grades = grades[best_student]

print(
    f"Best student {best_student}, "
    f"max score {max(best_grades)}, "
    f"min score {min(best_grades)}."
)

输出:

Best student Ben, max score 12, min score 4.
5 年前
回复了 Mateen Ulhaq 创建的主题 » python中filter函数的代码在哪里?[副本]

正如@jim提到的,文件组织被描述为 here .为便于发现而复制:

对于python模块,典型的布局是:

Lib/<module>.py
Modules/_<module>.c (if there’s also a C accelerator module)
Lib/test/test_<module>.py
Doc/library/<module>.rst

对于仅扩展模块,典型布局为:

Modules/<module>module.c
Lib/test/test_<module>.py
Doc/library/<module>.rst

对于内置类型,典型布局为:

Objects/<builtin>object.c
Lib/test/test_<builtin>.py
Doc/library/stdtypes.rst

对于内置功能,典型布局为:

Python/bltinmodule.c
Lib/test/test_builtin.py
Doc/library/functions.rst

一些例外情况:

builtin type int is at Objects/longobject.c
builtin type str is at Objects/unicodeobject.c
builtin module sys is at Python/sysmodule.c
builtin module marshal is at Python/marshal.c
Windows-only module winreg is at PC/winreg.c