jupyter notebook--常用操作記錄
一、jupyter notebook中魔法操作
1.將本地的.py文件load到jupyter的一個cell中
%load test.py
2.從網絡load代碼到jupyter
%load http://.....,
3.jupyter中運行python文件
%run file.py
4.python程序中中文註釋
#--*-- coding:utf-8 --*--
5.在jupyter notebook中以命令行形式運行python命令,安裝包等
!python --version #查看python版本
!python test.py #執行test.py程序文件
! pip install opencv2 # 安裝程序
6.獲取當前的工作空間current working directory
!current_path = %pwd
7.使用matplotlib繪圖
%matplotlib inline
8.在jupyter中設置link
[需要添加鏈接的文字](#the_destination)
需要在要跳轉到的位置添加下面語句:
<a id = 'the_destination'> </a>
9.在jupyter notebook中添加目錄功能
利用Anaconda安裝Jupyter Notebook extensions
conda install -c conda-forge jupyter_contrib_nbextensions
二、jupyter中常用快捷鍵
執行當前cell,並自動跳到下一個cell:Shift Enter
執行當前cell,執行後不自動調轉到下一個cell:Ctrl-Enter
是當前的cell進入編輯模式:Enter
退出當前cell的編輯模式:Esc
刪除當前的cell:雙D
爲當前的cell加入line number:單L
將當前的cell轉化爲具有一級標題的maskdown:單1
將當前的cell轉化爲具有二級標題的maskdown:單2
將當前的cell轉化爲具有三級標題的maskdown:單3
爲一行或者多行添加/取消註釋:Crtl /
撤銷對某個cell的刪除:z
瀏覽器的各個Tab之間切換:Crtl PgUp和Crtl PgDn
快速跳轉到首個cell:Crtl Home
快速跳轉到最後一個cell:Crtl End