In [2]: %logstart Activating auto-logging. Current session state plus future input saved. Filename : ipython_log.py Mode : rotate Output logging : False Raw input log : False Timestamping : False State : active
# 查看变量或函数 In [4]: ?a Type: int String form: 1 Docstring: int(x=0) -> intor long int(x, base=10) -> intor long
# 打印函数的源码 In [15]: func?? Signature: func() Source: deffunc(): print("hello world") File: /<ipython-input-13-4475a92670e6> Type: function
内置命令-执行文件代码 (%run)
1 2 3 4 5 6 7 8 9 10
In [29]: !vi test.py
In [30]: !cat test.py deffunc1(): print("hello world")
func1()
In [31]: %run "test.py" hello world
目录书签系统 (%bookmark)
目录书签,类似于快捷方式
1 2 3 4 5 6 7 8 9 10 11 12
# 定义 local 书签 In [37]: %bookmark local /usr/local # 查看所有书签 In [38]: %bookmark -l Current bookmarks: local -> /usr/local # 使用书签. In [39]: cd local (bookmark:local) -> /usr/local /usr/local # 覆盖之前书签 In [41]: %bookmark local /etc/sysconfig
In [11]: %debug > <ipython-input-10-0ee88489e9f0>(1)<module>() ----> 1 func%debug ipdb>
设置断点单步调度 %run -d script.py
s 进入脚本 , b 13# 在13行设置断点 c # continue till touch the break point n # 执行下一行。 如果有exception 报出:throws_an_exception , ipdb> s # 单步进入 exception 那行. ipdb> !a #在变量a 前加 ! 查看 变量内容