2

pls correction with correct syntax pythoh piece of Code that cause error:

def reliable_send(self, data):
        json_data = json.dumps(data)
        self.connection.send(json_data)

Error is:

self.connection.send(json_data) at json_data whic is

TypeError: a bytes-like object is required, not 'str'

1 Answer 1

2

you need to encode the data before sending, this should be the solution

def reliable_send(self, data):
    json_data = json.dumps(data)
    self.connection.send(json_data.encode())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.