I'm working on a python 3 project that does the exact same thing as bash's 'wc' (Word count) command. The format for input looks like this:
$ python3 myWC.py < fileName.txt
I'd like to use the file given to count over the bytes, words, and lines in the file and print them. I've tried using stdin but even simple print() statements seem to be printing stdin's object instead of the actual string given. Could someone give me some guidance on basic stdin usability in Python 3? Thank you!
As pointed out below, I was using '>' instead of '<'. But now when I run this code:
import sys
def main():
word = sys.stdin.readline()
print(word)
main()
I simply get a blank line as output in Terminal