获取呼叫命令,哪些管道进入python脚本

发布于 2025-01-25 23:58:04 字数 156 浏览 3 评论 0原文

我有一个python脚本,可以通过管道读取数据:

cat file.txt | sort | script.py

我可以获取呼叫命令cat file.txt | sort作为script.py中的字符串?

I have a python script which reads data via pipe like this:

cat file.txt | sort | script.py

Can I get the calling command cat file.txt | sort as a string in script.py?

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

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

发布评论

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

评论(1

熊抱啵儿 2025-02-01 23:58:04

如果要调用cat file.txt |从python脚本中进行排序,您可以执行以下

import os
os.sytem("cat file.txt | sort")

os.system()将从cat file.txt |排序

希望这就是您想要的。

If you want to call cat file.txt | sort from your python script, you could do the following

import os
os.sytem("cat file.txt | sort")

os.system() would return the output from cat file.txt | sort.

Hope this is what you are looking for.

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