Error - Exception: a bytes-like object is required
Error - Exception: a bytes-like object is required
# Error - Exception: a bytes-like object is required
The error a bytes-like object is required, not ‘str’ occurs when you try to perform an operation that expects a bytes object (binary data), but you provide a str object (text).
This issue is common when working with Python 3, as str and bytes are distinct types.
- Fix:
1
sock.send("Hello, Server!".encode('utf-8')) # Convert string to bytes
This post is licensed under CC BY 4.0 by the author.