在PyCharm中使用其他注释样式注释掉代码

时间:2018-07-15 21:18:18

标签: python pycharm comments

在使用PyCharm注释掉文本时(通过选择文本并点击键盘快捷键),它会使用常规的#注释,如下所示:

enter image description here

我不喜欢它与实际的注释看起来很相似(即我解释了我的代码的作用),因此它想使用其他样式的注释(##)来注释掉代码:

def execute_evil_master_plan():
    ## # Start by hijacking a government satellite.
    ## # Doesn't matter which as long as it has a death laser.
    ## satellite = hijack_government_satellite()
    ## 
    ## # aim it towards the white house and fire the laser
    ## coords = google_maps.get_coordinates(WHITE_HOUSE)
    ## satellite.aim(target=coords)
    ## satellite.fire()

在PyCharm中是否可以自定义注释样式?

1 个答案:

答案 0 :(得分:0)

在多行注释之前和之后使用“”。

def execute_evil_master_plan():
    """
    # Start by hijacking a government satellite.
    # Doesn't matter which as long as it has a death laser.
    satellite = hijack_government_satellite()

    # aim it towards the white house and fire the laser
    coords = google_maps.get_coordinates(WHITE_HOUSE)
    satellite.aim(target=coords)
    satellite.fire()
    """