import sys
fileobject=open('file.txt','w')
fileobject.write(sys.stdin.readline())
Cat
In the above code, shouldn't cat be in file after execution? However, when I run it, I find file empty. If my code is wrong, can someone explain how sys.stdin.read()
and sys.stdout.write()
work and their uses?