user705260
user705260

Reputation: 278

Reading file in python without linebreak

I want to be able to read a file and add a string onto it line by line without having a line break in the middle.

text_file = open("read_it.txt", "r")
print text_file.readline() + "0123456789"

Outputs to

>>
text
0123456789
>>

I would like have it output to this format

>>
text0123456789
>>

Upvotes: 1

Views: 1499

Answers (1)

Howard
Howard

Reputation: 39177

Use the rstrip method:

text_file.readline().rstrip() + "0123456789"

Upvotes: 6

Related Questions