02 - ipython

ipython

(anacoda) - (集成了)
ipython
pip3 install ipython
 
ipython
 

练习

In [20]: 1+2
Out[20]: 3
 
In [40]: a
Out[40]: [1, 2, 3]
 
In [41]: a.__**?
a.__add__
a.__class__
 
In [42]: a?
Type:        list
String form: [1, 2, 3]
Length:      3
Docstring:
list() -> new empty list
list(iterable) -> new list initialized from iterable's items
 
In [43]: a??
Type:        list
String form: [1, 2, 3]
Length:      3
Docstring:
list() -> new empty list
list(iterable) -> new list initialized from iterable's items
 
In [91]: %run test.py
hello world
 
In [98]: def fun(x):
    ...:     print(x)
    ...: fun("hello")
    ...:
hello
 
In [99]: %paste
def fun(x):
        print(x)
fun("hello")
 
## -- End pasted text --
hello
 
In [110]: a=1
In [111]: b=2
In [112]: a+b
Out[112]: 3
 
In [113]: %timeit a+b
40.1 ns ± 0.195 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
 
In [6]: %pdb on
Automatic pdb calling has been turned ON
 
In [7]: def test(a,b):
   ...:     c = a/b
   ...:     print(c)
   ...:     return c
   ...:
   ...: a=3
   ...: b=0
   ...: test(a,b)
   ...:
   ...:
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-7-213e7d1a610e> in <module>()
      6 a=3
      7 b=0
----> 8 test(a,b)
 
<ipython-input-7-213e7d1a610e> in test(a, b)
      1 def test(a,b):
----> 2     c = a/b
      3     print(c)
      4     return c
      5
 
ZeroDivisionError: division by zero
> <ipython-input-7-213e7d1a610e>(2)test()
      1 def test(a,b):
----> 2     c = a/b
      3     print(c)
      4     return c
      5
 
ipdb> p a
3
ipdb> p b
0
 
In [8]: %pdb off
Automatic pdb calling has been turned OFF
 
In [9]: %pdb on
Automatic pdb calling has been turned ON
 
In [55]: 1+2
Out[55]: 3
In [56]:
In [56]: _  # 获取输出
Out[56]: 3
In [65]: _i58   # 获取输入
Out[65]: 'a*b'
 
bookmark使用:
%bookmark proj 'C:\\Users\\白静'
%bookmark home ~
%bookmark -l
cd proj
%bookmark -d home
%bookmark -r
 
 
ipython高级功能:
 
 
ipython常用的魔术命令:
 
pdb调试器常用的命令:
 
ipython快捷键:
 
 
 
posted @ 2018-11-11 14:45  Alice的小屋  阅读(89)  评论(0编辑  收藏  举报