python执行子进程实现进程间通信的好办法!

时间:2018-05-11 关注公众号 来源:3lian.com

python执行子进程实现进程间通信的好办法!

  

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程序设计有所帮助。

扫码关注“ 多特资源库
更多更全的软件资源下载
文章内容来源于网络,不代表本站立场,若侵犯到您的权益,可联系我们删除。(本站为非盈利性质网站)
玩家热搜

相关攻略

正在加载中
版权
版权说明

文章内容来源于网络,不代表本站立场,若侵犯到您的权益,可联系我们删除。(本站为非盈利性质网站)

电话:13918309914

QQ:1967830372

邮箱:rjfawu@163.com

toast