Python学习之IPython/IPython notebook篇
来源:互联网 发布:excel中可以编程吗 编辑:程序博客网 时间:2024/05/22 14:53
导言
可以在cmd中,进入python环境,但是交互性能实在是接近于无。我们可以使用IPython提供的交互环境,进行数据分析等活动。IPython Shell具备以下特性:
1. Tab completion, which helps you find a command
2. History mechanism
3. Inline editing
4. Ability to call external Python scripts with %run
5. Access to system commands
6. The pylab switch
7. Access to the Python debugger and profiler
包含使用频繁的自动补全等功能。下面介绍交互体验较好的几种方式。
pylab switch
pylab switch
自动导入Scipy,Numpy,matplotlib。
$ ipython -pylabType "copyright", "credits" or "license" for more information.IPython 2.0.0-dev -- An enhanced Interactive Python.? -> Introduction and overview of IPython's features.%quickref -> Quick reference.help -> Python's own help system.object? -> Details about 'object', use 'object??' for extradetails.Welcome to pylab, a matplotlib-based Python environment[backend: MacOSX].For more information, type 'help(pylab)'.
可使用logstart
存储session记录。
In [1]: %logstartActivating auto-logging. Current session state plus futureinput saved.Filename : ipython_log.pyMode : rotateOutput logging : FalseRaw input log : FalseTimestamping : FalseState : active
使用logoff
停止记录。
IPython notebook
介绍
IPython Notebook是web based IPython封装,但是可以展现富文本,使得整个工作可以以笔记的形式展现、存储,对于交互编程、学习非常方便。
IPython Notebook使用浏览器作为界面,向后台的IPython服务器发送请求,并显示结果。在浏览器的界面中使用单元(Cell)保存各种信息。Cell有多种类型,经常使用的有表示格式化文本的Markdown单元,和表示代码的Code单元。
每个代码单元都有一个输出区域,在Code单元中输入代码,按 Shift-Enter 将运行此代码,代码中最后一个表达式的值将输出区域显示。如果希望屏蔽输出,可以在最后一条语句之后添加一个分号:”;”。此外,代码中还可以使用print语句在输出区域中显示信息。
IPython Notebook的设计目的是让数据分析更容易分享和再生,目前用它来给科研做详细记录、设计教学模型以及与他人合作,其科学家用户已越来越多。
Windows中IPython Notebook的安装需要pyreadline、pyzmq、tornado、mathjax
等工具的支持,使用了pip进行安装,安装过程非常方便快捷。
使用方法与示例
- 打开cmd,切换到工作目录,输入
ipython notebook
即可打开服务器。 - 显示一张图片:
from IPython.display import Image
- 可以选择Markdown风格
- 在函数,模块,类后面输入
?
,按ctrl+enter
,即可跳转到其定义;输入??
,对应可得到源码 - %load可以从文件或者网址载入代码到一个新的单元中,例如下面载入某个matplotlib的示例程序,并执行
%load http://matplotlib.org/mpl_examples/pylab_examples/histogram_demo.py - %prun用于代码的执行性能分析,可以作为行命令和单元命令使用
部分参考
- Python学习之IPython/IPython notebook篇
- python ipython notebook教程
- Python学习笔记(二)-- iPython notebook
- Python在云端编程之IPython notebook
- ipython notebook
- Ipython notebook
- ipython notebook
- ipython+notebook
- IPython notebook
- ipython notebook
- ipython notebook
- ipython + notebook
- ipython notebook
- Python: IPython notebook快捷键(Jupyter notebook)
- Spark之python版机器学习算法--ipython notebook配置及测试
- Python之IPython
- Python,Jupyter Notebook,IPython快速安装教程
- Python,Jupyter Notebook,IPython快速安装教程
- POJ-1251-Jungle Roads(最小生成树 克鲁斯卡尔)
- elasticsearch 安装、插件
- H5流式播放(FMP4转封装与mediaSource)
- PHP.ini中session设置
- Java中数据类型
- Python学习之IPython/IPython notebook篇
- Scrapy爬虫 - 获取知乎用户数据
- esp8266-SDK的串口发送和中断接收
- elasticsearch CRUD Sense
- 求斐波那契数列的前10项,并逆序输出,用数组实现
- 3dmax入门教程(一)
- iOS 更改全局字体
- 第十三周阅读程序 虚析构函数
- Spring(三)——核心容器Bean