欢迎来到山村网

python执行子进程实现进程间通信的方法

2019-03-02 13:46:02浏览:489 来源:山村网   
核心摘要:  本文实例讲述了python执行子进程实现进程间通信的方法。分享给大家供大家参考。具体实现方法如下:  a.py:  ? 1234567i

  本文实例讲述了python执行子进程实现进程间通信的方法。分享给大家供大家参考。具体实现方法如下:

  a.py:

  ?

1 2 3 4 5 6 7 import subprocess, time subproc = subprocess.Popen(['c:python31python.exe', 'c:/b.py'], stdin=subprocess.PIPE, shell=True) time.sleep(0.5) print('start') subproc.stdin.write('datan') subproc.communicate('datan') print('end')

  b.py:

  ?

1 2 3 4 import sys print('receive...') s = sys.stdin.readline() print('get:', len(s), s)

  希望本文所述对大家的Python程序设计有所帮助。

(责任编辑:豆豆)
下一篇:

c#操作iis根目录的方法

上一篇:

Python多进程并发(multiprocessing)用法实例详解

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com