发送方
#coding:utf-8
from socket import *
updSocket = socket(AF_INET,SOCK_DGRAM)
updSocket.sendto("hahhaha".encode('utf-8'),("192.168.4.7",7777))
接收方
#coding:utf-8
from socket import *
#接受方 必須綁定端口
updSocket = socket(AF_INET,SOCK_DGRAM)
updSocket.bind(("192.168.4.16",7777)) #绑定端口
data= updSocket.recvfrom(1024) #就收其他地方的数据
print(data)
updSocket.close()
网友评论