我尝试用python 2.7打开100个pdf文件,代码如下:
import arcpy,fnmatch,os
rootPath = r"D:\desktop"
pattern = '*.pdf'
counter = 0
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
os.startfile(rootPath)
counter = counter + 1
print counter
结果,rootPath文件夹打开,python打印pdf文件的数量:
^{pr2}$没有打开pdf文件。我在论坛里搜索,没有找到任何问题可以回答我的请求。谢谢你的帮助
你总是打电话来
其中
^{pr2}$rootPath
只有"D:\desktop"
。必须以PDF文件的路径作为参数调用os.startfile
。在我不知道你想做什么,但是
os.startfile
将打开adobepdf阅读器(或其他设置为默认阅读器的阅读器)。。。我是如何做到这一点的,而且似乎奏效了。在或者不需要大量编辑主代码
^{pr2}$相关问题 更多 >
编程相关推荐