我设置了一个批处理文件来运行一个创建 .pdf 输出的 ghostscript,然后我想在后续的 python 脚本中使用它。批处理文件本身运行没有问题,看起来像这样:
"%PROGRAMFILES%\gs\gs9.54.0\bin\gswin64c.exe" -dBATCH -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dAutoRotatePages=/PageByPage -r600 -sOutputFile=%~dp0\%result%.pdf -
^&
"%~dp0\test.py" %result%.pdf
批处理文件日志显示它执行了所有命令。此外,一个只记录它运行的日志的虚拟 python 脚本也可以完美运行。但是,当我用 dummy 替换我想要使用的脚本时,尽管从控制台单独运行时文件运行完美,但文件并没有做它应该做的事情。 python 脚本如下所示:
import os
import sys
from rmapy.document import ZipDocument
from rmapy.api import Client
# sets up the current directory to be the same as the .py file
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# sets up the remarkable api
rm=Client()
rm.renew_token()
# finds the pdf
for arg in sys.argv[1:]:
print(arg)
rawDocument = ZipDocument(doc=arg)
rawDocument.metadata["VissibleName"]
rm.upload(rawDocument)
非常感谢您提供的任何帮助。我怀疑 .py 文件中的某些内容在通过批处理文件调用时会产生错误,但我不知道是什么。