gpt4 book ai didi

python-2.7 - python错误无法从python打开应用程序中的pdf

转载 作者:行者123 更新时间:2023-12-03 16:38:30 25 4
gpt4 key购买 nike

我正在使用 windows 10 和 python 2.7.13 。我的目标是在特定页码的acrobat reader中打开pdf。我正在使用我从此处论坛中的一个问题中收到的代码。

import subprocess
import os

path_to_pdf = os.path.abspath('C:\test_file.pdf')
# I am testing this on my Windows Install machine
path_to_acrobat = os.path.abspath('C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe')

# this will open your document on page 12
process = subprocess.Popen([path_to_acrobat, '/A', 'page=12', path_to_pdf], shell=False, stdout=subprocess.PIPE)
process.wait()

它打开了 acrobat 阅读器应用程序,但文件没有打开,我收到错误消息:“打开此文档时出错。文件名、目录名或卷标语法不正确

但是当我在没有 python 的情况下在 cmd 中使用这些命令时,我能够成功地打开 pdf 而没有任何错误。请帮忙。

最佳答案

尝试用r打开文件:

path_to_pdf = os.path.abspath(r'C:\test_file.pdf')
path_to_acrobat = os.path.abspath(r'C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe')

Check this out too , 它会向您显示路径上的空格错误的示例

关于python-2.7 - python错误无法从python打开应用程序中的pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44094170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com