Jun-17-2020, 11:26 PM
Why are you calling
But udp.sendto sends bytes, not strings. If you want to send the string in a UTF-8 encoding, you can pass the string to encode() and that will generate a bytes object.
hex()
on those values? That takes a number and returns a python string.But udp.sendto sends bytes, not strings. If you want to send the string in a UTF-8 encoding, you can pass the string to encode() and that will generate a bytes object.
>>> type("foo") <class 'str'> >>> type("foo".encode()) <class 'bytes'>If you instead want to send the raw bytes, you'll need to look at
struct.pack()