471,337 Members | 896 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

httplib module

Why do I get double new lines when geting data from server? Example:

I have a following file:
------start-------------
<html>
<body>
Ovo je testni primjerak
</body>
</html>
------end---------------

And the code is:
conn = httplib.HTTPConnection("localhost:8000")
conn.request("GET", "/folder/index.html")
response = conn.getresponse()
reply = response.read()

print reply
<html>\n\n<body>\n\nOvo je testni primjerak\n\n</body>\n\n</html>\n\n

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 7 '07 #1
4 1344
Boris Ozegovic wrote:
Why do I get double new lines when geting data from server? Example:
Fixed.

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 7 '07 #2
Boris Ozegovic wrote:
Boris Ozegovic wrote:
>Why do I get double new lines when geting data from server? Example:

Fixed.
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 7 '07 #3
Steve Holden wrote:
>>Why do I get double new lines when geting data from server? Example:
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.
Ok. In do_GET I had this two lines:

for line in file:
print line

As you can see, print inserted another \n. :-)

Correct code is:

for line in file:
print line,

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 8 '07 #4
Boris Ozegovic wrote:
Steve Holden wrote:
>>>Why do I get double new lines when geting data from server? Example:
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.

Ok. In do_GET I had this two lines:

for line in file:
print line

As you can see, print inserted another \n. :-)

Correct code is:

for line in file:
print line,
Thanks. Glad you got it sorted out.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 8 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by berklee just berklee | last post: by
2 posts views Thread by scummer | last post: by
1 post views Thread by Brian Beck | last post: by
reply views Thread by Robert | last post: by
2 posts views Thread by James Stroud | last post: by
5 posts views Thread by scott | last post: by
5 posts views Thread by runningwild | last post: by
4 posts views Thread by Patrick Altman | last post: by
3 posts views Thread by rhXX | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.