Passing \ n (new line) in stdout throught sys argument

This is elementary, I think:

Consider this snippet:

for i in range(3): sys.stdout.write(str(i) + '\n') 

of

 0 1 2 

and this:

 for i in range(3): sys.stdout.write(str(i) + sys.argv[1]) 

out (after passing \ n as an argument):

 0\n1\n2\n 

So how can I pass new-line as an argument?

+4
source share
1 answer
  sys.stdout.write (str (i) + sys.argv [1] .decode ("string_escape")) 
+8
source

All Articles