在ipython中使用%history快速查找历史命令

1、输出所有历史记录,且带有序号

 %history -n

 150: %cpaste
 151: %cpaste
 152: print(r">>>>>>>>>")
 153: print(r'>>>>>>>>>')
 154: print(r'>>>>>>>>><')
 155: print(r'>')
 156: print(r'>>')
 157: print(r'>>>')
 ...

2、按序号,查找某些序号区间的历史纪录

 %history -n 168-170 178 185-190
 
 168: planets
 169:
for method, group in planets.groupby('method'):
    print(f'{method:30s} method={group}')
 170:
for method, group in planets.groupby('method'):
    print(f'{method:30s} method={group.shape}')
 178: %history?
 185: %history -u
 186: %history -n -u
 187: ?%history
 188: %history -g method
 189: %history -g method print
 190: %history -g for method,

3、模糊查找

 %history -g print*metho*

 120:
for method, group in planets.groupby('method'):
    print(f"{method:30s} shape={groupe.shape}")
 121:
for method, group in planets.groupby('method'):
    print(f"{method:30s} shape={group.shape}")
 169:
for method, group in planets.groupby('method'):
    print(f'{method:30s} method={group}')
 170:
for method, group in planets.groupby('method'):
    print(f'{method:30s} method={group.shape}')
 182:
for method, group in planets.groupby('method'):
     print(f"{method:30s shape=group.shape}")
 198: %history -g print*metho*

你可能感兴趣的:(#,ipython)