typeerror a bytes-like object is required not 'str' socket file.write code example Example: TypeError: a bytes-like object is required, not 'str' 'Hello World'.encode()