python - 将 Python 模块划分为多个区域

在 C# 中,我们可以使用

创建区域
#region
// some methods
#endregion

有没有办法以类似的方式格式化 python 代码,以便我可以将所有相关方法保存在一个 block 中?

最佳答案

看起来 PyCharm 有它,请看这里:https://www.jetbrains.com/help/pycharm/2016.1/code-folding.html#using_folding_comments

对于 Python 文件,支持以下两种样式。您不应该将它们混合在一个文件中。

#<editor-fold desc="Description">
...
#</editor-fold>

#region Description
...
#endregion

Visual Studio 也接受“区域”

https://stackoverflow.com/questions/8265583/

相关文章:

powershell - 哈希表数组上的格式表

hadoop - hadoop namenode 格式到底是什么?

python - 如何在 Python logging.Formatter 中右对齐级别字段

visual-studio - 如何更改 Visual Studio 自动格式

objective-c - 在 Objective C 中格式化 float

algorithm - 模糊日期算法

javascript - 如何在 chrome 控制台中完全打印大数组?

c# - Visual Studio 格式化整个文件?

c# - 如何将百分比字符串转换为双倍?

string - 在 Excel 中将时间字段转换为字符串