标签:ddr soc listen com img accept data info png
客户端:
import socket
client = socket.socket()
client.connect(("localhost",6969))
while True:
msg = input("我要发数据>>:").strip()
print("开始发送数据: "+msg)
client.send(msg.encode("UTF-8"))
client.close()
运行截图:
服务器端:
import socket
sever = socket.socket()
sever.bind(("localhost",6969))
sever.listen()
print("开始接受数据")
coon,addr = sever.accept()
while True:
data = coon.recv(1024).decode()
print("收到数据: "+data)
# coon.send(data)
sever.close()
标签:ddr soc listen com img accept data info png
原文地址:https://www.cnblogs.com/erikchanBolg/p/10216141.html