[Tutor] help on raw_input()
ceasar102 at yahoo.com
Sat Apr 14 14:59:10 CEST 2007
Thanks the encode method really helps.
Alan Gauld <alan.gauld at btinternet.com> wrote: "ammar azif" wrote
> Actually i wanted to write a http client using just he low level
> socket module.
I won;t ask why! But the httplib module probably does what you want
just in case you dodn't realize it existed...
> The program will prompt the user asking for input and the
> use will type http commands like
> 'GET /index.html HTTP/1.0\r\nHost: somehost\r\n\r\n'
OK, So you want the user to acrtually type \,n,\,n and you
will then send that string to be interpreted as newlines?
> when i use the raw_input function , the string that i get is
> 'GET /index.html HTTP/1.0\\r\\nHost: somehost\\r\\n\\r\\n'
The double \\ doesn''t actually exist its just Python telling you
that it is a literal \ character not an escaped sequence.
As I said earlier if you check the len() of the string it will
only have one character per backslash.
I think it's already doing what you want!
You just need to turn the \n's that the user entered into
newline characters, Kent has shown you how to do that
with the decode() method...
Author of the Learn to Program web site
Tutor maillist - Tutor at python.org
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor