Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lynkynpark86

macrumors 6502
Original poster
I'm using readlines, and if I do
Code:
print 'Loading %s...' % (stringFromReadlines)
It prints this:
Loading TheTextLoadedFromFile
...

Notice the ... is on a new line. Why is this happening? It's like the string contains a line break.
 
That is probably the case then, a line is ended with a newline symbol. At least the readline() includes the newline.

So how do I avoid this? I need to have multiple lines in my file, and this only happens on the first line. How could I fix this?
 
So how do I avoid this? I need to have multiple lines in my file, and this only happens on the first line. How could I fix this?

I don't know, strip the new line manually? Perhaps there is a more sensible way of solving it with Python, look at the docs.
 
I don't know, strip the new line manually? Perhaps there is a more sensible way of solving it with Python, look at the docs.

Figured it out! Not sure how clean it will be, but
Code:
theString = theString.replace('\n','')
seems to work fine. Thanks for the help!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.