使用子进程,它superseeds
os.popen,尽管它是没有太大的一个抽象的更多:
from subprocess import Popen, PIPEoutput = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]#this is how I'd mangle the arguments togetheroutput = Popen([ self._ghostscriptPath, 'gswin32c', '-q', '-dNOPAUSE', '-dBATCH', '-sDEVICE=tiffg4', '-r196X204', '-sPAPERSIZE=a4', '-sOutputFile="%s %s"' % (tifDest, pdfSource),], stdout=PIPE).communicate()[0]
如果只有python 2.3而没有子进程模块,则仍然可以使用os.popen
os.popen(' '.join([ self._ghostscriptPath, 'gswin32c', '-q', '-dNOPAUSE', '-dBATCH', '-sDEVICE=tiffg4', '-r196X204', '-sPAPERSIZE=a4', '-sOutputFile="%s %s"' % (tifDest, pdfSource),]))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)