【发布时间】:2017-07-14 13:41:06
【问题描述】:
你好,我有很多 pdf 文件,我想使用 python 转换为 .eps。
我找到了一些代码,但对我不起作用,代码执行时没有错误,但我没有获取一些 .eps 文件。
有什么想法吗?
我有 python 2.7.13
代码 1:
from glob import *
from os import system
fileList = glob('*.pdf')
for f in fileList:
system('pdftops -eps {0}'.format(f))
代码 2:
import os, re, sys
dirList = os.listdir( '.' )
try:
os.mkdir( 'EpsFigs' )
except:
pass
for f in dirList:
m = re.match('([\w\-]+).(|jpg|jp2|png|pdf|)$',f)
if m:
cmd = 'convert %s EpsFigs/%s.eps'%( f, m.group(1) )
os.system(cmd)
【问题讨论】:
-
为什么不直接通过命令行转换呢?
-
@RomanPerekhrest 怎么样?