0

I want to make a simple application hello.py in python that prints the piped string, so that when I call

echo "Hello StackOverflow" | python3 hello.py

The python app prints

Hello StackOverflow

What do I write in my hello.py file?

0

1 Answer 1

1
import sys

for line in sys.stdin:
    sys.stdout.write(line)

Input:

echo "Hello StackOverflow" | python3 hello.py

Output:

Hello StackOverflow
Sign up to request clarification or add additional context in comments.

1 Comment

Yep, tried it out, it works!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.