![](/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.