Basically my question is the title,
so for example in shell:
>>> import sys
>>> sys.stdout.write('Hello')
Hello5
(same with stderr
)
But from a file:
import sys
sys.stdout.write('Hello')
Output:
Hello
(same with stderr
)
So why is this happening???
That's the return value. sys.stdout.write('Hello')
returns 5
, which gets printed automatically in interactive mode, but not in a script.