簡體   English   中英

在 Visual Studio 代碼中注釋 python 代碼

[英]comment python code in visual studio code

當嘗試使用組合鍵ctrl + shift + a注釋代碼塊時,我的 Visual Studio 代碼使用'''而不是使用#注釋 python 代碼。 我有 ubuntu 16.04

對於 VS Code 和 Python ,

  • 選擇代碼塊

  • 要發表評論,請按 CTRL + k + c

  • 對於取消評論,請按 CTRL + k + u

這與 Visual Studio 沒有什么特別關系,而是 Python 注釋樣式的結果。 通常,單行注釋是用磅(或哈希)符號完成的:

# This is a comment

相比之下,可以使用三個引號(''' 或 """)輕松生成多行注釋。

'''
This is also a comment.
However, this comment crosses multiple lines
'''

"""
This is yet another multiline comment
For long comments the quotation marks are much easier than # comments.
"""

希望這會有所幫助。

在 Windows 環境下,這對我有用:

  • 選擇塊文本
  • CTRL + /

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM