Read a blog, very good. Http://www.cnblogs.com/turtle-fly/p/3280519.html
The standard output (sys.stdout) corresponds to print (printing), and the standard input (Sys.stdin) corresponds to the input (receive input) operation, and the standard error output and standard output are similar to print (printing).
Python's most basic operation-printing:
1
The effect is to write 1 in the console (command line) to let you see.
In fact, his operation can be understood as: the console (command line) as a board, through the Sys.stdout = console designated to the console board to write things (console is the default, that is, you do not change where to write, it will be written by default) , in print 1, just tell Python that I'm going to write 1, and then Python will go to the board specified by Sys.stdout, which is the console (command line) that writes 1.
(The standard error output is the same process, and you'll find that when the program goes wrong, the error message is printed in the console.) )
In fact, as long as an object has the Write method, it can be used as a "board", tell Sys.stdout where to write.
Speaking of the Write method, the first thing you might think of is file manipulation.
F=open ('log.txt','w')
To declare a file object F as above, this file object has the Write method, which can be used as the standard output and categorization malleability the error output of the board.
F=open ('log.txt','w')__console__ = Sys.stdout # make a backup of the default "board"-command line so that it can be changed back = fprint 1
__console__
Print 2
The above operation, by sys.stdout = f Specifies that the board is changed to F when printing. So when using print, it is no longer to print 1 on the command line, but in the Log.txt file.
And then changed the board to the command line, and then print 2 prints 2 to the command line.
Python takes standard output (sys.stdout) as an example to see Python's standard input, standard error output