ipython how to execute several history lines

前端 未结 7 1523
梦谈多话
梦谈多话 2021-01-30 14:04

In ipython, we can use

_ih[32:39] 

To show history lines between 32 and 39. How can I directly execute these history lines?

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 14:40

    You can execute code from previous sessions with %recall. See %recall documentation here.

    #Execute all code from previous session.
    %recall ~1/
    
    #Execute all code from two sessions previous the current session.
    %recall ~2/
    
    #Execute lines 1 to 5 from previous session.
    %recall ~1/1-5
    

提交回复
热议问题