gpt4 book ai didi

python - 如何在 python 中通过 shell 管道接收参数?

转载 作者:IT王子 更新时间:2023-10-29 00:26:18 26 4
gpt4 key购买 nike

我想做这样的事情:

find -name "foo*" | python main.py

并访问查找程序找到的所有文件。我如何在 Python 中访问它?

最佳答案

import sys
for line in sys.stdin:
print line

关于python - 如何在 python 中通过 shell 管道接收参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6106437/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com