[Tutor] Getting rid of the newline in file

Joseph Quigley cpu.crazy at gmail.com
Sat Sep 17 06:35:15 CEST 2005


Hi. I'm using
f = file("foo", 'w')
fileContents = f.readlines()
print fileContents[0] + "Hi!"

and I get:

Foo
Hi!

How can I get rid of that new line? fileContents[1] has Bar.
I wrote the file using Joe (a *nix test editor) and for the new line I
pressed Enter to add Bar.
This is a pain as I don't want the newline.

Thanks,
    Joe
(No coincidence between my fav. text editor and my name!)





More information about the Tutor mailing list