liubulong 发表于 2019-11-29 09:36:52

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

最近在看《利用python进行数据分析》,作者推荐使用ipython,我就去查了一下,比原本的python shell好用多啦,特别对于我这种不喜欢用IDE工具,喜欢直接在服务器写的代码的小白来说
找了一篇文章,给大家介绍一下python shell和ipython的却别,希望对大家有用


原文链接:https://blog.csdn.net/ztf312/article/details/78677093

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有很多快捷键



ipython的扩展宏系统

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

autoreload自动重载;


参考资料

(简单版)https://www.zhihu.com/question/51467397?from=profile_question_card

(全面版)https://www.cnblogs.com/zzhzhao/p/5295476.html

页: [1]
查看完整版本: 【Python】选择ipython替代python的理由