import socketserver
class MyServer(socketserver.BaseRequestHandler):
def handle(self):
while True: #self.request==conn
ret=self.request.recv(1024).decode('utf-8')
print(ret)
if ret=='q':
break
msg=input('>>>')
self.request.send(('王良书:'+msg).encode('utf-8'))
if __name__=='__main__':
sk=socketserver.ThreadingTCPServer(('127.0.0.1',8080),MyServer)
sk.serve_forever()