以前在我的PPTpython高级编程也提到了一些关于ipython的用法. 今天继续由浅入深的看看ipython, 本文作为读者的你已经知道ipython并且用了一段时间了.
这是一个magic命令, 能把你的脚本里面的代码运行, 并且把对应的运行结果存入ipython的环境变量中:
123456789 | $cat t.py# coding=utf-8l = range(5) $ipythonIn [1]: %run t.py # `%`可加可不加 In [2]: l # 这个l本来是t.py里面的变量, 这里直接可以使用了Out[2]: [0, 1, 2, 3, 4] |
123456789 | In [3]: %alias largest ls –1sSh | grep %sIn [4]: largest tototal 42M 20K tokenize.py 16K tokenize.pyc8.0K story.html4.0K autopep84.0K autopep8.bak4.0K story_layout.html |
PS 别名需要存储的, 否则重启ipython就不存在了:
12 | In [5]: %store largestAlias stored: largest (ls –1sSh | grep %s) |
下次进入的时候%store -r
12345678910 | In [2]: %pwdOut[2]: u\’/home/vagrant\’ In [3]: %bookmark dongxi ~/shire/dongxi In [4]: %cd dongxi/home/vagrant/shire/dongxi_code In [5]: %pwdOut[5]: u\’/home/vagrant/shire/dongxi_code\’ |
其实ipython提供的方便的并行计算的功能. 先回答ipython做并行计算的特点:
1.
$wget http://www.gutenberg.org/files/27287/27287–0.txt
第一个版本是直接的, 大家习惯的用法.
1234567891011121314151617181920212223242526272829303132333435363738394041424344 | In [1]: import re In [2]: import io In [3]: non_word = re.n-5812a3edcff54237149273-5\”>In [3]: non_word = re.运行, 并且把对应的运行结果存入ipython的环境变量中:
alias
PS 别名需要存储的, 否则重启ipython就不存在了:
下次进入的时候 bookmark – 对目录做别名
ipcluster – 并行计算其实ipython提供的方便的并行计算的功能. 先回答ipython做并行计算的特点: 1. 第一个版本是直接的, 大家习惯的用法.
|