tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = input("请输入连接的服务的IP:") port = int(input("请输入服务的端口:")) tcp_socket.connect((host, port)) th_send = threading.Thread(target=send_msg, args=(tcp_socket,)) th_recv = threading.Thread(target=recv_msg, args=(tcp_socket,)) th_send.start() th_recv.start()