Skip to content

Instantly share code, notes, and snippets.

@Albert-W
Last active February 20, 2020 12:26
Show Gist options
  • Save Albert-W/fe8a62f350ab062bb24da654847f7d67 to your computer and use it in GitHub Desktop.
Save Albert-W/fe8a62f350ab062bb24da654847f7d67 to your computer and use it in GitHub Desktop.
jupyter01
安装
conda install -c conda-forge notebook jupyter.org/install
conda install -c conda-forge jupyter_contrib_nbextensions 安装插件
魔法命令
%run myscript/hello.py 执行脚本
%timeit L = [i**2 for i in range(1000)] 统计时间,多次平均
%time L = [i**2 for i in range(1000)] 统计时间,单次
%lsmagic 查看其他魔法命令
Linux 命令
!ls
directory = !pwd!
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
临时配置多行输出
vim ~/.ipython/profile_default/ipython_config.py
c = get_config()
c.InteractiveShell.ast_node_interactivity = "all"
重启jupyter notebook
持久配置多行输出
nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator
Hinterland 代码提示
Snippets 代码片段
Autopep8 美化代码
Gist-it 保存到gist
ipywidgets
1 # pip
2 pip install ipywidgets
3 jupyter nbextension enable --py widgetsnbextension
4 # Conda
5 conda install -c conda-forge ipywidgets
6 #Installing ipywidgets with conda automatically enables the extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment