我从Windows命令行运行ipython。我想知道ipython中是否有一个功能允许我暂时转到shell(cmd.exe),然后返回当前的ipython会话。
我知道使用"!"执行shell命令。但那不是我想要的。
Folks提出了一个有效的解决方案,所以我回答了它here。
答案 0 :(得分:2)
您可以通过在iPython中执行命令!cmd
来启动新的控制台shell。当您退出该控制台时,您将返回到iPython提示符。
这类似于使用!sh
或!bash
创建子shell的UNIX技巧。
答案 1 :(得分:1)
Folks评论并提出了一种方法 - 使用!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]: