繁体   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