从https://stackoverflow.com/a/6193800/2375044开始,我正在尝试在 Python 3.3/Linux 上使用管道,但是如果我使用以下命令,则程序“挂起”:
import os
readEnd, writeEnd = os.pipe()
readFile = os.fdopen(readEnd)
firstLine = readFile.readline()
更改os.fdopen(readEnd)
为os.fdopen(readEnd, 'r+')
我得到
io.UnsupportedOperation: File or stream is not seekable.
我需要管道上的 readline() 函数,但我不知道还能做什么。