Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError
#2
Why are you calling 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()
Reply


Messages In This Thread
TypeError - by omega_elite - Jun-17-2020, 11:05 PM
RE: TypeError - by bowlofred - Jun-17-2020, 11:26 PM
RE: TypeError - by omega_elite - Jun-17-2020, 11:49 PM
RE: TypeError - by bowlofred - Jun-18-2020, 06:53 AM
RE: TypeError - by omega_elite - Jun-18-2020, 09:45 AM
RE: TypeError - by bowlofred - Jun-18-2020, 04:38 PM
RE: TypeError - by omega_elite - Jun-18-2020, 11:08 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020