To receive input from stdin in python 2.7, I typically import sys
and use sys.stdin
. However, I have seen examples where raw_input
is used to receive input from stdin, including multi-line input. How exactly can I use raw_input in place of sys.stdin? Here is an example problem:
input.txt:
Print
me
out
And I am running this command:
cat input.txt | python script.py
What can I put in script.py such that it will print out all lines of input using raw_input
?