2024-10-02 02:45:03 发布
网友
请使用正确的语法进行更正导致错误的pythoh代码段:
def reliable_send(self, data): json_data = json.dumps(data) self.connection.send(json_data)
错误为:
self.connection.send(json_数据)在json_数据中
TypeError:需要类似字节的对象,而不是“str”
您需要在发送之前对数据进行编码,这应该是解决方案
def reliable_send(self, data): json_data = json.dumps(data) self.connection.send(json_data.encode())
您需要在发送之前对数据进行编码,这应该是解决方案
相关问题 更多 >
编程相关推荐