execute the following line in terminal,
python test.py < sample.txt
Outputs,
hello world
Why does it only display the first line of the sample.txt ?
How to update test.py to display all the lines ??
I want to use the file redirection method only
Any thoughts would be appreciated.
Happy learning
Use sys.stdin
Also, to clarify, input only accepts until the first newline character. If you need more, use a loop or something.
Обсуждают сегодня