ipython:临时进入shell,稍后返回当前的ipython会话

3
我正在从Windows命令行运行ipython。我想知道是否有一个功能可以让我暂时进入shell(cmd.exe),然后返回到当前的ipython会话。
我知道使用“!”来执行shell命令。但那不是我想要的。
有人建议了一个可行的解决方案,我在这里回答了:here

3
除了使用 ! 运行 shell 命令之外,你的意思是什么? - Martijn Pieters
@MartijnPieters 是的,除此之外。谢谢你提醒。 - KFL
1
我自己不用Windows,但是!cmd.exe会有任何有用的作用吗? - Martijn Pieters
1
尝试使用 !start,也许会起作用。 - Ashwini Chaudhary
2
既然你已经找到了解决方案,那么你可以将其作为自己问题的答案。 - int3
显示剩余2条评论
2个回答

2

在iPython中执行命令!cmd可以启动一个新的控制台窗口。当您退出该控制台时,将返回到iPython提示符。

这类似于使用!sh!bash在UNIX中创建子shell的技巧。


1

大家评论并建议了一种可行的方法 - 使用!cmd或!powershell启动新的命令会话,并通过退出该shell返回。

例如:

C:\>ipython
Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]:

In [1]: !cmd
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\>exit

In [2]:

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接