用Python写一个模拟qq聊天小程序的代码实例-创新互联
Python 超简单的聊天程序
乐都ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!客户端:
import socket, sys host = '10.248.27.23' # host = raw_input("Plz imput destination IP:") # data = raw_input("Plz imput what you want to submit:") port = 51423 s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: s.connect((host, port)) except socket.gaierror, e: print "Address-related error connecting to server: %s" %e sys.exit(1) except socket.error, e: print "Connection error: %s" %e sys.exit(1) while 1: try: data = raw_input("I say: ") s.send(data) buf = s.recv(1024) if len(buf): print "he say: "+buf except: print "Dialogue Over" s.close() sys.exit(0)
标题名称:用Python写一个模拟qq聊天小程序的代码实例-创新互联
当前链接:http://pwwzsj.com/article/dojgop.html