Python2.x:socket.send(string[, flags])
Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. For further information on this concept, consult the Socket Programming HOWTO.
Python3socket.send(bytes[, flags])
Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. For further information on this topic, consult the Socket Programming HOWTO.
您用python2和python3标记了问题,但是python2.x和python3中的socket.send()是不同的。{{n2>在pytho3}中,它可以像pytho3}那样传递对象。在
您传递的是bytes,但它是python内置类型,而不是像object那样的字节。在
您可以尝试s.send(output_str.encode()),它会将编码的输出字符串发送到客户端(一旦客户端接收到数据,它就必须对其进行解码)。在