[英]open (display) pdf files in Sikuli
I want to open (display) in adobe reader pdf files from my directory of pdf files in Sikuli. 我想从我的Sikuli pdf文件目录中的adobe reader pdf文件中打开(显示)。 I manage to do this for one file: 我设法做到一个文件:
import os
import subprocess
file = 'C:/Users/.../pdf/test3.pdf'
subprocess.Popen([file],shell=True)
This works fine. 这很好。
Now, I want to do this for each pdf file in my directory. 现在,我想对目录中的每个pdf文件执行此操作。 Here is my code so far: 到目前为止,这是我的代码:
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)
But it is not working. 但这是行不通的。 Can someone plase help me to get the for
statement right? 有人可以帮助我获得正确的for
陈述吗?
Thank you in advance! 先感谢您!
Try this: 尝试这个:
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)
You need to provide fullpath of pdf file, not just the filename. 您需要提供pdf文件的完整路径,而不仅仅是文件名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.