(转)【Python】选择ipython替代python的理由

https://blog.csdn.net/ztf312/article/details/78677093

登陆linux环境,已安装Anaconda,最常用的就是输入“python”,进入python环境。偶然看到师弟用ipython进入环境,好奇查询了以下区别。

python shell与ipython的区别:

(1) python shell不能在退出保存历史;

ipython历史记录自动保存:

        保存在history.sqlite文件下:

可用“_”、“__”、“___”调用最近三次记录;

(2) python shell不支持tab自动补全;

ipython支持tab补全;

(3) python shell不能快速获取类、函数信息;

ipython通过“?”显示对象签名、文档字符串、代码位置,通过“??”显示源代码;

(4) python shell不能直接执行shell命令,需要借助sys;

ipython通过“!”调用系统命令,如“!uptime”;

(5) 其他

ipython有很多magic函数,可通过使用%lsmagic枚举;

%run:运行python文件

%edit:使用编辑器打开当前函数编辑

%save:把某些历史记录保存到文件

%debug:激活debug程序

%timeit:获得程序执行时间

%paste:获取剪切板文件并执行,最好用%cpaste,可通过Ctrl+C中断

ipython有很多快捷键

storemagic持久化宏、变量、别名;

autoreload自动重载;

ipython的扩展宏系统

猜你喜欢

转载自blog.csdn.net/zyb418/article/details/86155572