复制代码,使用–退出
In :%cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:
查看历史
In :hist -n
1: my_macro
2: hist -n
3: a = 1
4: b = 2
5: c = 3
6: hist -n
保存文件
In :save test.py 3-5
File `test.py` exists. Overwrite (y/[N])? y
The following commands were written to file `test.py`:
a = 1
b = 2
c = 3
编辑文件,会使用默认的编辑器
In :edit test.sh
Editing... done. Executing edited code...
导入文件
In :load test.sh
In :!sh test.sh
to,121,112,223
In :cat test.sh
#!/bin/bash
array_name=("to","121","112","223")
for data in ${array_name[@]}
do
echo "$data"
done
测试执行时间
In :%timeit for _ in range(10000): 1
10000 loops, best of 3: 173 µs per loop
In :%timeit for _ in xrange(10000): 1
10000 loops, best of 3: 119 µs per loop
In :time range(10)
CPU times: user 3 µs, sys: 0 ns, total: 3 µs
Wall time: 3.81 µs
Out:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
保持现场
In :logstart 1017.py
Activating auto-logging. Current session state plus future input saved.
Filename : 1017.py
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
In :a = 1
In :b = 2
In :c =3
In :c = 3
In :logoff
Switching logging OFF
root@zidy ~ >> ipython -i 1017.py
Activating auto-logging. Current session state plus future input saved.
Filename : 1017.py
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
Switching logging OFF
In :a
Out:1
In :b
Out:2
In :c
Out:3
标记路径
In :%bookmark
UsageError: %bookmark: You must specify the bookmark name
In :%bookmark book /root/book/
In :cd book
/root/book
In :pwd
Out:u'/root/book'
常用命令
? 显示方法参数,说明等
?? 显示方法的源码
_ 上一次的返回值
修改IPython提示符
ipython profile create
mv /root/.ipython/profile_default/ipython_config.py /root/.ipython/profile_default/ipython_config.py1
cp ipython_config.py /root/.ipython/profile_default/ipython_config.py
ipython_config.py需要下载,