![](/img/trans.png)
[英]VS Code Auto-Formatter Automatically Adds Lines Between Comments and Class
[英]Auto save adds two empty lines between comment and function header in Python in VS code
这是由于 Python 的代码约定 (PEP8)。 Pylance 将在保存时更正您的代码。
这是 PEP8 的摘录,您可以在这里找到:
You should use two spaces after a sentence-ending period.
如果注释描述了您的函数,请尝试使用 Docstrings。
注释记录函数行为应放在函数内部,就在签名下方。 如果它没有描述功能(放在功能之外),它应该有那些空行。 不要乱用语言的约定,这是非常糟糕的主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.