对PyCharm中注释掉的代码使用不同的注释样式

2024-05-19 08:57:11 发布

您现在位置:Python中文网/ 问答频道 /正文

当用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中定制这样的评论风格?在


Tags: the代码文本风格asitcoords键盘
1条回答
网友
1楼 · 发布于 2024-05-19 08:57:11

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

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()
    """

相关问题 更多 >

    热门问题