开发者

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
>>


Use the rstrip method:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜