我正在从Windows命令行运行ipython。我想知道是否有一个功能可以让我暂时进入shell(cmd.exe),然后返回到当前的ipython会话。
我知道使用“!”来执行shell命令。但那不是我想要的。
有人建议了一个可行的解决方案,我在这里回答了:here。
我知道使用“!”来执行shell命令。但那不是我想要的。
有人建议了一个可行的解决方案,我在这里回答了:here。
在iPython中执行命令!cmd
可以启动一个新的控制台窗口。当您退出该控制台时,将返回到iPython提示符。
这类似于使用!sh
或!bash
在UNIX中创建子shell的技巧。
大家评论并建议了一种可行的方法 - 使用!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]:
!
运行 shell 命令之外,你的意思是什么? - Martijn Pieters!cmd.exe
会有任何有用的作用吗? - Martijn Pieters!start
,也许会起作用。 - Ashwini Chaudhary