How do I comment out multiple lines in Jupyter Ipy

2019-01-16 02:14发布

I want to comment out a block of multiple lines in Jupyter (Ipython Notebook), but can't find out how to do that in this current version.
It used to be in one of the drop down menus but is no longer there.
How do you comment out multi-line blocks of code at once?

This is not a duplicate because the solution given in the following link doesn't seem to work anymore:
How can I block comment code in the IPython notebook?

Ctrl + / does nothing.

18条回答
疯言疯语
2楼-- · 2019-01-16 02:52

Fn + Cmd + / in Safari browser on MacOS

查看更多
成全新的幸福
3楼-- · 2019-01-16 02:54

Try using the / from the numeric keyboard. Ctrl + / in Chrome wasn't working for me, but when I used the / from the numeric it worked.

查看更多
▲ chillily
4楼-- · 2019-01-16 02:55

I add the same situation and went in a couple of stackoverfow, github and tutorials showing complex solutions. Nothing simple though! Some with "Hold the alt key and move the mouse while the cursor shows a cross" which is not for laptop users (at least for me), some others with configuration files...

I found it after a good sleep night. My environment is laptop, ubuntu and Jupyter/Ipython 5.1.0 :

Just select/highlight one line, a block or something, and then "Ctrl"+"/" and it's magic :)

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-16 02:55

I am using chrome, Linux Mint; and for commenting and dis-commenting bundle of lines:

Ctrl + /

查看更多
贪生不怕死
6楼-- · 2019-01-16 02:56

For a Dutch keyboard layout (on Debian 9 in Chromium 57) it is Ctrl + °

查看更多
等我变得足够好
7楼-- · 2019-01-16 02:58

Use triple single quotes ''' at the beginning and end. It will be ignored as a doc string within the function.

'''
This is how you would
write multiple lines of code
in Jupyter notebooks.
'''

I can't figure out how to print that in multiple lines but you can add a line anywhere in between those quotes and your code will be fine.

查看更多
登录 后发表回答