How do I pipe output from one python script as input to another python script?

后端 未结 3 424
[愿得一人]
[愿得一人] 2021-01-25 05:59

For example:

A script1.py gets an infix expression from the user and converts it to a postfix expression and returns it or prints it to stdout

script2.py gets a

3条回答
  •  遇见更好的自我
    2021-01-25 06:38

    For example if you have nginx running and script1.py:

    import os
    
    os.system("ps aux")
    

    and script2.py

    import os
    
    os.system("grep nginx")
    

    Then running:

    python script1.py | script2.py
    

    will be same as

    ps aux | grep nginx
    

提交回复
热议问题