5
popen2的我試圖運行從書的「弗雷德·倫德」 Python標準庫「的代碼。子替換使用Python
import popen2, string
fin, fout = popen2.popen2("sort")
fout.write("foo\n")
fout.write("bar\n")
fout.close()
print fin.readline(),
print fin.readline(),
fin.close()
它與
~/python_standard_library_oreilly_lunde/scripts/popen2-example-1.py:1: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
警告如何翻譯與子先前的功能運行良好?我嘗試如下,但它不起作用。
from subprocess import *
p = Popen("sort", shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
p.stdin("foo\n") #p.stdin("bar\n")
*有些錯誤*? – SilentGhost 2010-10-08 16:44:14