On 03/22/2013 11:29 PM, Lolo Lolo wrote:
using a socket im trying to send a message between connections. it was a string and my python
complained:
> "TypeError: must be bytes or buffer, not str" .. so i put a b infront
of the string. now this works fine but the problem is after recieving
this message, i need to send it back with an int included, like:
> message = 'Thankyou!, processed connection number %d' % connections
connections being an int.
> again this is a string, but puttng a b infront of that strong wont
work, it returns:
> TypeError: unsupported operand type(s) for %: 'bytes' and 'int'
>
> i tried everything but i cant seem to get past this little obstacle.
im using python 3 on windows vista
>
>
> _______________________________________________
>
You can use bytes() function:
bytes('%d' % 3, 'utf-8')
b'3'
-m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
Whenever you find yourself on the side of the majority, it is time to
pause and reflect. Mark Twain
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor