Jupyter Notebook的安装及基本操作
Jupyter Notebook的安装及基本操作

Jupyter Notebook以前被称为IPython notebook。是一个交互式笔记本,支持运行40多种编程语言。它的本质是Web应用程序,可以理解为运用浏览器编写Python文件。

一般用于数据清理和转换、数值模拟、统计建模、机器学习。

关于Jupyter Notebook的安装
开放式安装Jupyer Notebook的先决条件

这里介绍了两种安装方法,第一种就是下载Anaconda安装,会自动安装上Python、Jupyter以及大量常用的Python数据包。

第二种就是常规的,在Python中使用pip安装Jupyter。
这里我们推荐使用第一种安装方法。

接下来介绍Jupyter的使用,点击开始菜单,在Anaconda目录下点击Jupyter Notebook。

它会弹出这样一个页面,在文件路径中选择相应的文件即可打开。

如果想新建一个,点击NEW,下拉选项中选择对应的类型即可,这里以Python为列





新建Notebook建立由名字、主工具栏、快捷栏和编辑区几个部分组成。

编辑区由许多的cell单元格组成。


Jupyter的常用操作,运行操作,在单元格中输入代码,例如:print('Hello,world'),点击快捷栏中的运行按钮,或者直接使用快捷键shift+Enter,运行代码会显示结果同时会切换到新的单元格中。

插入操作,点击主工具栏Insert,在下拉菜单中选择Insert Cell Above或者Insert Cell Below 在当前单元格的上方或者下方插入。

快捷栏当中的插入按钮默认当前单元格的下方插入。

移动操作,在单元格输入print(‘hello python’),点击主工具栏中的Edit。

在下拉菜单中选择Move Cell Down或者Move Cell Up,将当前单元格向上或者向下移动。

删除单元格,点击Edit,在下拉菜单中选择Delete Cells删除当前单元格。

合并操作,在Edit下拉菜单中选择Merge Cell Above(Below),将当前单元格向上或者向下合并。

分离操作,选择Edit下拉菜单中Split Cell,即可将光标左右的代码分离在两个cell中。

添加标题,点开Cell下拉菜单中Cell Type 中Markdown,即可修改当前的单元格类型。

这个标题以一个#开头表示一级标题,两个#表示二级标题,以此类推。在#后方输入标题并且运行即可添加标题,提高代码的可读性。


重命名操作,可以直接点击名字在弹出的窗口中输入新的名字点击Rename。

也可在File下拉菜单中点击Rename修改。

除了上诉的操作,还有很多常用的菜单,
View:用于修改Notebook的界面。
Cell:用于单元格的运行等相关操作。
Kernel:用于内核的相关操作。
Widget:常用工具的相关操作。

更多操作请关注官方网站的文档。