标签:安装 导致 系统 except int code file python开发 无法
Python开发菜鸟入坑
项目要求pdf转成图片,网上较多的方案对于windows极其不友好,wand,Pythonmagick(win下载地址:www.lfd.uci.edu/~gohlke/pythonlibs/#pythonmagick),imagemagick(win下载地址:www.imagemagick.org/download/),poppler(win下载地址://blog.alivate.com.au/poppler-windows/)等多个方案尝试后仍然不行,并且第三方的模块安装导致了window系统爆炸,无法正常使用(大概是window不太适合编程),于是决定去看pdf2image库源码(https://github.com/Belval/pdf2image),现分享pdf2image小demo,亲测有用。
from pdf2image import convert_from_path import os def demo(): try: images = convert_from_path(‘filename‘) for idx, img in enumerate(images): path=‘{}.jpg‘.format(idx) img.save(os.path.join(‘./img/‘,path,‘JPEG‘,quality=100)) except Exception as e: print(e) if __name__==‘__main__‘: demo()
标签:安装 导致 系统 except int code file python开发 无法
原文地址:https://www.cnblogs.com/zj-Rules/p/10124833.html