标签:int ddr while highlight div print 编码 socket class
import socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) while True: client_socket.sendto(input(‘请输入要回显的数据:‘).encode(), (‘127.0.0.1‘, 23234)) client_recv_temp_data = client_socket.recvfrom(1024) print(‘回显数据是:‘, client_recv_temp_data[0].decode())
服务端这里不需要编码或者解码,直接回发就行
import socket socket_serve = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) addr = (‘‘,23234) socket_serve.bind(addr) while True: recv_temp = socket_serve.recvfrom(1024) socket_serve.sendto(recv_temp[0], recv_temp[1])
标签:int ddr while highlight div print 编码 socket class
原文地址:https://www.cnblogs.com/wf-skylark/p/9104445.html