簡體   English   中英

在Sikuli中打開(顯示)pdf文件

[英]open (display) pdf files in Sikuli

我想從我的Sikuli pdf文件目錄中的adobe reader pdf文件中打開(顯示)。 我設法做到一個文件:

import os
import subprocess 

file = 'C:/Users/.../pdf/test3.pdf'
subprocess.Popen([file],shell=True) 

這很好。

現在,我想對目錄中的每個pdf文件執行此操作。 到目前為止,這是我的代碼:

import os
import subprocess 

source = 'C:/Users/.../pdf'
for root, dirs, filenames in os.walk(source):
    for file in filenames:
        subprocess.Popen([file],shell=True)

但這是行不通的。 有人可以幫助我獲得正確的for陳述嗎?

先感謝您!

嘗試這個:

import os
import subprocess 

source = 'C:/Users/.../pdf'
for root, dirs, filenames in os.walk(source):
    for file in filenames:
        if file.endswith('.pdf'):
            pdf_fullpath = os.path.join(root, file)
            subprocess.Popen([pdf_fullpath],shell=True)

您需要提供pdf文件的完整路徑,而不僅僅是文件名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM