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