#coding = utf - 8 import socket #建立socket套件 s = socket . socket () ip_port = ( "127.0.0.1" , 9956 ) #建立连接 s . connect ( ip_port ) send_data = input ( ":" ). strip () #发消息 s . send ( bytes ( send_data , encoding = "utf-
import socket
#建立socket套件
s=socket.socket()
ip_port=("127.0.0.1",9956)
#建立连接
s.connect(ip_port)
send_data=input(">>>:").strip()
#发消息
s.send(bytes(send_data,encoding="utf-8"))
#受消息
recv_data=s.recv(1024)
print(str(recv_data,"utf-8"))
s.close()
socket只处理数据而不是发送数据