On 26/02/17 18:42, Alan Gauld via Tutor wrote:
On 26/02/17 06:44, Phil wrote:

s.connect((host, 1210))
data = "GET_LIST"

This is a string, you need to use bytes.

data = bytes("GET_LIST",'utf8')


Thank you Peter and Alan for your response.

Converting "data" to bytes worked, of course. Now I have to, I think, do the opposite to the received data.

while 1:
    buf = s.recv(2048)
    if not len(buf):
        break
    print("Received: %s" % buf)

This prints the correct result like this:

b'ABC\DEF\ETC\n' n/

Instead of:

ABC
DEF
ETC

I tried str.decode(buf) but doesn't seem to be the answer.

--
Regards,
Phil
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to