subprocess.Popen stdin read file

前端 未结 3 1239
一整个雨季
一整个雨季 2020-12-03 11:41

I\'m trying to call a process on a file after part of it has been read. For example:

with open(\'in.txt\', \'r\') as a, open(\'out.txt\', \'w\') as b:
  hea         


        
3条回答
  •  长情又很酷
    2020-12-03 12:05

    It happens because the subprocess module extracts the File handle from the File Object.

    http://hg.python.org/releasing/2.7.6/file/ba31940588b6/Lib/subprocess.py

    In line 1126, coming from 701.

    The File Object uses buffers and has already read a lot from the file handle when the subprocess extracts it.

提交回复
热议问题