+ 1
Which statement will associate file object "fileLog" to the standard output stream (options in description)
1) fileLog= open("Filelog.log","w") 2) sys.stdout = fileLog 3) out = open("Filelog.log","w") 4) os.stdout= fileLog
1 Réponse
+ 1
You need to open the file first with the open method (option 1) and then associate sys.stdout with the file stream (option 2).
I would recommend to save the output status beforehand in a variable like: saved = sys.stdout.
To option 3: it's effectively the same as option 1, but the stream is saved in a other variable.
And there is no os.stdout in the os package.