提问人:LaikaN57 提问时间:4/26/2017 更新时间:4/26/2017 访问量:75
在 Python 中将 infile 连接到 outfile
Connecting an infile to an outfile in Python
问:
所以我有两个对象,每个对象都有一个输入和输出流。我想连接它们(在 Python 3 中)。有没有办法映射:
a.in = b.out
b.in = a.out
或者,我是否有两个为每个方向编写一个轮询器?例如。这:
def thread_a():
while(c = a.in.getc()):
b.out.put(c)
def thread_b():
while(c = b.in.getc()):
a.out.put(c)
答: 暂无答案
评论
def client(ip, port, message): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.connect((ip, port)) sock.sendall(bytes(message, 'ascii')) response = str(sock.recv(1024), 'ascii') print("Received: {}".format(response))