相关疑难解决方法(0)

Python中的目录树列表

如何获取Python中给定目录中所有文件(和目录)的列表?

python directory file subdirectory directory-tree

559
推荐指数
10
解决办法
62万
查看次数

在 Python 的子进程中使用 Windows 路径(指向可执行文件)[初学者]

我开始在安装了 cygwin(Python 2.7)的 Windows 7 x64 机器上开发一个小的 pdf 到 jpg 脚本。以下工作完美:

import subprocess
filename = "test"
subprocess.check_output('gs -sDEVICE=jpeg -dPDFFitPage -g2800x3620 -o ' + filename + '-2800-%03d.jpg ' + filename + '.pdf', stderr=subprocess.STDOUT)
Run Code Online (Sandbox Code Playgroud)

在我的 Windows 10 x64 非 Cygwin 机器(Python 2.7)上拉取此项目后,此代码错误,因为它不再将“gs”识别为 ghostscript 的内置缩写。所以我尝试以下操作:

import subprocess
filename = "test"
subprocess.check_output('C:\Program Files\gs\gs9.20\bin\gwin64c.exe -sDEVICE=jpeg -dPDFFitPage -g2800x3620 -o ' + filename + '-2800-%03d.jpg ' + filename + '.pdf', stderr=subprocess.STDOUT)

WindowsError: [Error 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)

好吧,我是初学者,在这里犯了一些明显的错误。"\b"中间的字符也.20\bin\被突出显示......向我表明我不知何故没有明确这是一条单一的路径。

我也尝试过的事情(单独运行): …

windows executable subprocess cmd python-2.7

3
推荐指数
1
解决办法
6601
查看次数