Python中的中线评论? [英] Mid-line comment in Python?
问题描述
我想知道是否有任何方法来注释掉一部分行,就像你可以在c ++中使用 / * this * /
。我知道的唯一的评论是#this
它总是到行的结尾,这些
,这不工作中线。
I'm wondering if there is any way to comment out part of a line, like you can do in c++ with /*this*/
. The only comments I know about are # this
which always goes to the end of the line and the """these"""
ones, which do not work mid-line.
示例use-case:使用子进程,需要暂时从列表中注释掉一个参数 -p 0
Example use-case: using subprocess and need to temporarily comment out an argument -p 0
from the list:
['../some/guy', '-m', '10', '-p', '0', '-n', '100', '-f', '/dev/stdout']
这将是一个很好的键盘快捷方式注释选择,目前我只是复制整行如下
It would be nice to have a keyboard shortcut to comment out a selection, at the moment I just copy the whole line as below
#['../some/guy', '-m', '10', '-p', '0', '-n', '100', '-f', '/dev/stdout']
['../some/guy', '-m', '10', '-n', '100', '-f', '/dev/stdout']
我期待着一个大胖的'不',但我想它不伤害问,python已经惊讶我几次前。
I'm expecting a big fat 'no' but I suppose it doesn't hurt to ask, python has surprised me a few times before.
推荐答案
您是正确的,答案是大胖 。
You are correct, the answer is a big fat NO.
这篇关于Python中的中线评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!