ipython 常用命令
来源:互联网 发布:神舟软件科技有限公司 编辑:程序博客网 时间:2024/06/07 11:33
1.pylab模式启动ipython
ipython --pylab
2.tab自动补全
3.%run 执行py脚本
test.py
def test(x): return x + 1tmp = test(5)
In [1] : %run test.pyIn [2] : tmpOut[2] : 6
4.“!”使用系统shell执行命令
- 使用系统shell执行命令
In [3] : !pwd/User/***/codespace
- 将系统shell执行命令后到输出值赋给变量
In [5] : a = !pwdIn [6] : aOut[6] : ['/User/***/codespace']
5.“%time”计算代码执行时间
- 计算一行代码到执行时间
In [1]: str = ['foo', 'foobar', 'baz', 'qux', 'python', 'test']*100000In [2]: %time test1 = [x for x in str if x.startswith('foo')]CPU times: user 279 ms, sys: 15.5 ms, total: 295 msWall time: 287 msIn [3]: %time test1 = [x for x in str if x[0:3] == 'foo']CPU times: user 123 ms, sys: 4.71 ms, total: 128 msWall time: 127 ms
- 自动多次执行并计算执行平均时间
In [9]: x = "foobar"In [10]: %timeit x.startswith("foo")The slowest run took 4.49 times longer than the fastest. This could mean that an intermediate result is being cached.1000000 loops, best of 3: 425 ns per loopIn [11]: %timeit x[0:3] == "foo"10000000 loops, best of 3: 182 ns per loop
阅读全文
0 0
- ipython常用命令
- ipython 常用命令
- Ipython常用命令
- IPython+交互式环境常用命令
- windows7安装ipython及常用命令
- Ipython
- Ipython
- ipython
- Ipython
- IPython
- ipython
- Ipython
- ipython
- Ipython
- ipython
- ipython
- IPython
- ipython
- selenium模拟登陆163邮箱
- sql server 程序集 更新 订单状态
- 51nod1163-优先队列-最高的奖励
- MBR简介
- Java校验IP的正则表达式
- ipython 常用命令
- 如何学习正则表达式(校验网址)
- hods--2000
- CodeForces
- 大暑假集训 第二阶段
- eclipse中中文乱码
- hdu6085 手写bitset
- bootstrap-datetimepicker精确到年、月、天、小时、分钟
- python模块下载网址