gpt4 book ai didi

python - 在 Python 中对常量变量使用大写字母是正确的形式吗?

转载 作者:行者123 更新时间:2023-12-05 09:23:10 29 4
gpt4 key购买 nike

在 Python 中声明常量的正确方法是:

MAX_FILESIZE = 10000

max_filesize = 10000

最佳答案

PEP 0008,Python 的官方风格指南,有一节是关于这个的 here :

Constants

Constants are usually defined on a module level and written in allcapital letters with underscores separating words. Examples includeMAX_OVERFLOW and TOTAL.

所以,第一个例子是正确的。

关于python - 在 Python 中对常量变量使用大写字母是正确的形式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24001393/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com