本文實例講述了python執行子進程實現進程間通信的方法。分享給大家供大家參考。具體實現方法如下:
a.py:
import subprocess, timesubproc = subprocess.Popen(['c:/python31/python.exe', 'c:/b.py'], stdin=subprocess.PIPE, shell=True) time.sleep(0.5)print('start')subproc.stdin.write('data/n')subproc.communicate('data/n')print('end')b.py:
import sysprint('receive...')s = sys.stdin.readline()print('get:', len(s), s)希望本文所述對大家的Python程序設計有所幫助。
新聞熱點
疑難解答
圖片精選