IPython is an upgraded version of the python interactive command-line tool.
ipython installation
pip install ipython
Wait until the command execution is complete display successfully
represents the completion of a successful installation
At the command prompt, enter ipython
you can start a ipython
With the original python command-line tool that ipython different prompt becomes in and out.
in
For local input commands, out
place the command output after completion of execution
ipython features
tab key autocomplete Some commonly used methods
Some systems support command
In [2]: pwd # 显示当前所在目录
Out[2]: '/root'
In [3]: cd .. # 返回当前目录的上一级目录
ipython notebook
installationjupyter
pip install jupyter
Display interface
At the command line, type:
jupyter qtconsole
( Note : Some articles would recommend input ipython qtconsole, this should be a little old version, has been deprecated and will be removed in a future version so it is best to use jupyter qtconsole..)
Running interface
Enter jupyter notebook on the command line (wait for it, it will automatically open a screen)
Click on a project to create a new-python3
There will be a new NoteBook
ipython commonly used magic command
%quickref 显示ipython的快速参考
%magic 显示所有的魔术命令的详细文档
%debug 从最新的异常跟踪的底部进入交互式调试器
%hist 打印命令的输入(可选输出)历史
%pdb 在异常发生后自动进入调试器
%paste 执行剪贴板中的python代码
%cpaste 打开一个特殊提示符以便手工粘贴待执行的python代码
%reset 删除interactive命名空间中的全部变量/名称
%page OBJECT 通过分页器打印输出object
%run script.py 在ipython中执行一个python脚本文件
%prun statement 通过cprofile执行statement,并打印分析器的输出结果
%time statement 报告statement的执行时间
%timeit statement 多次执行statement以计算系统平均执行时间.对那么执行时间非常小的代码很有用
%who,%who_id,%whos 显示interactive命名空间中定义的变量,信息级别/冗余度可变
%xdel variable 删除variable,并尝试清除其在ipython中的对象上的一切引用
python debugger command
h(help) 显示命令列表
help command 显示command的文档
c(continue) 恢复程序的执行
q(quit) 退出调试器,不再执行任何代码
b(break) n 在当前文件的第n行设置一个断点
b path/to/file.py:n 在指定文件的第n行设置一个断点
s(step) 单步进入函数调用
n(next) 执行当前行,并前进到当前级别的下一行
u(up)/d(down) 在函数调用栈中向上或向下移动
a(args) 显示当前函数的参数
debug statement 在新的递归调试器中调用语句statement
l(list) statement 显示当前行,以及当前栈级别上的上下文参考代码
w(where) 打印当前位置的完整栈跟踪(包括上下文参考代码)
ipython shortcuts
Ctrl+p或者向上键头 向后搜索命令历史中以当前输入的文本开头的命令
Ctrl+n或者向上键头 向前搜索命令历史中以当前输入的文本开头的命令
Ctrl+r 按行读取的反向历史搜索(部分匹配)
Ctrl+Shift+variable 从剪贴板粘贴文本
Ctrl+c 中止当前正在执行的代码
Ctrl+a 把光标移动到行首
Ctrl+e 把光标移动到行尾
Ctrl+k 删除从光标开始到行尾的文本
Ctrl+u 清除当前行的所有内容
Ctrl+f 将光标向前移动一个字符
Ctrl+b 将光标向后移动一个字符
Ctrl+l 清屏