"NighterNet" <darkne...@gmail.com> wrote in message news:55aba832-df6d-455f-bf34-04d37eb06...@i4g2000prm.googlegroups.com...
I am trying to figure out how to send text or byte in python 3.1. I am
trying to send data to flash socket to get there. I am not sure how to
work it.

buff= 'id=' , self.id , ':balive=False\n'
clientSock.send(buff);
--
http://mail.python.org/mailman/listinfo/python-list


Python 3.1 strings are Unicode (think characters not bytes). When writing to files, sockets, etc. bytes must be used. Unicode strings have an encode() method, where you can specify an appropriate encoding (ascii, latin-1, windows-1252, utf-8, etc.):

   clientSock.send(buff.encode('ascii'))

When reading from the socket, you can decode() the byte strings back into Unicode strings.

   data = clientSock.recv(1024).decode('ascii')

-Mark


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to