Deleting blank lines from Jupyter notebook

浪尽此生 提交于 2020-01-24 05:06:05

问题


Is there an easy way of removing blank lines from IPython notebook?

I have picked up a habit of blank lines from web development and my fingers tend to hit enter automatically. This makes IPython notebooks less(by taking too much of my 14" screen), not more readable in most cases.

I was wondering if there is a way of automatically remove blank lines from the notebooks.

In notebooks, I think preferred way of splitting the code is by placing each separate method to a different cell.

Is commonly accepted style guide for notebooks or does PEP 8 apply as it is?

EDIT: I think question 2, Is answered by IPython docs. https://github.com/ipython/ipython/wiki/Dev:-Coding-style


回答1:


If you are talking about deleting the empty line from jupyter notebook which opens in web browser then press Esc and D(keyboard key) 2 times.

You can also see all the keyboard shortcuts in the jupyter notebook file

by clicking on the help and then from dropdown on keyboard shortcuts.




回答2:


Pressing Esc and D (2 times) will delete only blank lines starting from the beginning. It won't delete any lines which have some text or code.




回答3:


I'm pretty sure you just have to do it manually. And you don't have to split code by putting it into different cells, in fact, I think its easy to not do that.



来源:https://stackoverflow.com/questions/42531056/deleting-blank-lines-from-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!