报错原因:
python3和Python2在套接字返回值解码上有区别。
import socket
s = socket.socket()
host = '127.0.0.1'
port = 8080
s.bind((host,port))
s.listen(5)
while True:
c,addr = s.accept()
print('连接地址:',addr)
str='1213'
c.send(str.encode())
c.close
import socket
s = socket.socket()
host = '127.0.0.1'
port = 8080
s.connect((host,port))
str = s.recv(1024)
str = str.decode()
print (str)
s.close()