python - 在 PyCharm 中对注释掉的代码使用不同的注释样式
问题描述
当使用 PyCharm 注释掉文本时(通过选择文本并点击键盘快捷键),它使用#
如下普通注释:
我不喜欢这看起来与实际注释有多么相似(即我解释我的代码做了什么),所以它想使用不同风格的注释 ( ##
) 来注释掉代码:
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 中自定义这样的评论样式?
解决方案
在多行注释前后使用 """。
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()
"""
推荐阅读
- python - 用单词替换各种格式的数字
- azure - 带有事件中心输出绑定的 Azure 函数不起作用
- python - 如何从网络 windows 目录获取文件并移动到我的 Python Django 项目目录?
- android - 无法使用 Mopub 在 android 中通过手动集成实现原生视频广告
- git - 创建管道时定义 jenkinsfile 脚本路径
- spring-portlet-mvc - 比较方法在向页面添加 portlet 时违反了其一般约定
- java - 如何从选择中排除元素(下拉)
- android - 未找到处理 Intent 的活动:ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
- java - Intellij 依赖树以编程方式
- docker - 无法删除 httpOnly:true secure: true cookie 在 docker 的量角器中使用无头 chrome 中的 deleteAllCookies()