import socket def soct(str_r): try: address = ('ip', 端口) client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(address) client.sendall(kk.encode()) #发送数据 client.settimeout(10) #设置超时时间 client.close() except Exception as e: return "失败 "+str(e)

庞玉栋个人博客、人生苦短-我用Python