config
enable plots in the notebook: %matplotlib inline
disable: %matplotlib
ipython nbconvert --to FORMAT notebook.ipynb
copy and add file on tail ipython nbconvert --to python
- html
- markdown
- python
魔力函数
%lsmagic可以列出所有的魔力函数 magic 也可以使用 魔力函数后面直接跟问好的形式 例如 %page?
%quickref # 起始部分是一个对IPython各种用法的引用,其余部分是对%magic函数的迷你总结,包括全部帮助信息的首行
%psearch np.diag* 寻找函数
numpy.lookfor('convolution')
commond
![command]
- !pwd
- %alias ls
- commands.getstatusoutput
!pwd
%run runpython文件 %who 查看定义变量 %who int 显示int的变量 %whos 显示变量值 %who_ls 返回列表 %who_ls int %reset 删除所有变量
%run my.py
%alias内嵌ls cd 等shell命令 %alias nss netstat -lptn
另一个可以简易执行shell命令的方法,是在命令前加一个感叹号(!)
通过$可以把python变量传递给shell命令
user = 'mouren'
process = 'bash'
!ps aux|grep $user |grep process
function
- %timeit
timeit x = 10
- %cpaste
- %debug allows you to enter post-mortem debugging. That is to say, if the code you try to execute, raises an exception, using %debug will enter the debugger at the point where the exception was thrown`
shortkey
Enter: edit mode
Shift-Enter: run cell, select below
Ctrl-Enter: run cell
Alt-Enter: run cell, insert below
esc+...
y: to code
m: to markdown
r: to raw
1: to heading 1
2: to heading 2
3: to heading 3
4: to heading 4
5: to heading 5
6: to heading 6
Up: select previous cell
Down: select next cell
k: select previous cell
j: select next cell
Ctrl-k: move cell up
Ctrl-j: move cell down
a: insert cell above
b: insert cell below
x: cut cell
c: copy cell
Shift-v: paste cell above
v: paste cell below
z: undo last delete
d: delete cell (press twice)
Shift-m: merge cell below
s: save notebook
Cmd-s: save notebook
l: toggle line numbers
o: toggle output
Shift-o: toggle output scrolling
q: close pager
h: keyboard shortcuts
i: interrupt kernel (press twice)
0: restart kernel (press twice)
Edit Mode (press Enter to enable)
Tab: code completion or indent
Shift-Tab: tooltip
Cmd-]: indent
Cmd-[: dedent
Cmd-a: select all
Cmd-z: undo
Cmd-Shift-z: redo
Cmd-y: redo
Cmd-Up: go to cell start
Cmd-Down: go to cell end
Opt-Left: go one word left
Opt-Right: go one word right
Opt-Backspace: del word before
Opt-Delete: del word after
Esc: command mode
Ctrl-m: command mode
Shift-Enter: run cell, select below
Ctrl-Enter: run cell
Alt-Enter: run cell, insert below
Ctrl-Shift--: split cell
Cmd-s: save notebook