0

I want to take input from a file(input.txt) into my .py file and display it in an output file(output.txt). I don't want to use file handling at all.

I tried following in terminal:

$ python3 hello.py > output.txt

and a file was created with the output.

But is there a method such that I can take input from a file to the .py file and it generates output.txt.

something like:

$ input.txt > python3 hello.py > output.txt
6
  • 2
    You were close : python3 hello.py < input.txt > output.txt Commented Jun 26, 2017 at 12:42
  • 1
    Thanks @Aaron it worked..!! :) Commented Jun 26, 2017 at 12:45
  • 1
    You're welcome ! I suggest you delete the question, because I'm certain there are a lot of duplicates (which is why I didn't post the solution in an answer) Commented Jun 26, 2017 at 12:47
  • @Aaron duplicates shouldn't be deleted, they should be linked to a dupe, dupes aren't bad they're different ways of expressing the problem that others might find Commented Jun 26, 2017 at 12:53
  • 1
    Possible duplicate of How to redirect standard input and output with Bash Commented Jun 26, 2017 at 14:33

0