+ 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

13th May 2021, 3:56 AM
Muskmello
Muskmello - avatar
1 ответ
+ 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.
5th Sep 2021, 3:51 PM
Strable
Strable - avatar