In the following code:
with open("output", "w") as f:
print >> f, "foo"
print >> f, "bar"
The 'output' file will be:
foo
bar
How to avoid newline and white spaces using print >>
?
P.S.: I'm actually wanting to know if it is possible to do it using print >>
. I know other ways in which I can avoid the '\n', such as f.write("foo")
and f.write("bar")
.
Also, I know about the trailing comma. But that prints foo bar
, instead of foobar
.