from time import *import subprocess# 打开程序第一个参数是一个列表(程序名称,参数)# 第二个参数是缓冲区大小# stdin,stdout是设置是否打开这些管道,如果他的值是subprocess.PIPE的话,# 就会打开,同stdin一样的还有stderrchild = subprocess.Popen(["python","in.py"], bufsize=1024, stdin=subprocess.PIPE,stdout=subprocess.PIPE)i = 0while True:if i > 10:breakelse:i += 1child.stdin.write(str(i).encode())child.stdin.write(b"\n")child.stdin.write(str(i+1).encode())child.stdin.write(b"\n")child.stdin.flush()fb = child.stdout.readline()print(fb.decode().strip())sleep(1)child.kill()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。