Windows上的python 2.3最好的方法是执行具有多个参数和路径中空格的ghostscript之类的程序吗?

Windows上的python 2.3最好的方法是执行具有多个参数和路径中空格的ghostscript之类的程序吗?,第1张

Windows上的python 2.3最好的方法是执行具有多个参数和路径空格的ghostscript之类的程序吗?

使用子进程,它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),]))


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5674797.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存