在 IPython 中运行外部命令

发布于 2024-09-12 17:13:41 字数 160 浏览 1 评论 0原文

我想从 IPython 配置运行一个新命令并捕获其输出。基本上,我想通过普通函数访问 !command 的等效项。我知道我可以只使用 subprocess,但由于 IPython 已经提供了此功能,我想 API 中的某个位置必须包含一个正确制作的包装器。

I'd like to run a new command from IPython configuration and capture its output. Basically, I'd like to access the equivalent of !command via normal functions. I know I can just use subprocess, but since IPython already provides this functionality, I guess there must be a properly made wrapper included somewhere in the API.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2024-09-19 17:13:41

显然,这样的包装器可以通过 ip.IP.getoutput("command") 来调用。

Apparently, such wrapper can be called via ip.IP.getoutput("command").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文