“must be str, not bytes”

后端 未结 2 1758
清歌不尽
清歌不尽 2021-01-29 09:06

I wrote a server on python:

import  socket
server_socket = socket.socket()
server_socket.bind((\'0.0.0.0\', 8820))

server_socket.listen(1)

(client_socket, clie         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-29 09:24

    You need to encode before sending a string. Example:

    mySocket.send("Hello".encode() + Client_name.encode())
    

    Or:

    mySocket.send(b"Hello" + Client_name.encode())
    

提交回复
热议问题