标签:nbsp serve pre sock main close send 服务器ip connect
1 import socket 2 3 4 def main(): 5 # 1.常见套接字对象 6 tcp_server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) 7 8 # 连接服务器 9 server_ip = input("请输入服务器ip:") 10 server_port = int(input("请输入端口号:")) 11 server_addr = (server_ip,server_port) 12 tcp_server_socket.connect(server_addr) 13 14 # 发送信息 15 send_msg = input("请输入发送内容:") 16 tcp_server_socket.send(send_msg.encode("gbk")) 17 18 # 关闭套接字 19 tcp_server_socket.close()
标签:nbsp serve pre sock main close send 服务器ip connect
原文地址:https://www.cnblogs.com/yifengs/p/11375905.html