0

I've been having an issue with input() redirection in Python 3.10.7.

Given Test1.py...

num1 = int(input())
print("Output is: ",num1)

...and Test1.txt...

345

...this command...

test1.py < test1.txt

...fails with the error...

At line:1 char:17
+ python test1.py < test1.txt
+ ~The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported

The script works fine when run from the command line. Trying to use the redirect fails with the error as seen above. Why?

Lance U. Matthews
  • 15,725
  • 6
  • 48
  • 68
BendBob
  • 11
  • 3
  • It's important to ensure your question is formatted properly and tagged appropriately. Are you calling `python` from PowerShell? If so, see [this answer](https://stackoverflow.com/a/70213162/150605). – Lance U. Matthews Sep 20 '22 at 01:11

0 Answers0