大佬教程收集整理的这篇文章主要介绍了pypdf2 命令将 pdf 转换为 html 失败并出现 TypeError:write() 参数必须是 str,而不是字节,pdfminer,,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用以下代码将多个 pdf 转换为 HTML:
@H_419_2@import os
for x in range(100) :
pathname = "/Users/supreet/Downloads/pdfLOCATIOn/"
filename = pathname + str(x+1) + ".pdf"
command = 'pdf2txt.py -o /Users/supreet/Downloads/HTMLFolder/'+str(x+1)+'.HTML -t HTML ' + filename
os.system(command)
该命令不久前运行良好,但半天后开始失败,不知道发生了什么, 这是错误日志:
@H_419_2@TraceBACk (most recent call last):
file "/Users/supreet/.pyenv/versions/3.9.1/bin/pdf2txt.py",line 115,in <module>
if __name__ == '__main__': sys.exit(main(sys.argv))
file "/Users/supreet/.pyenv/versions/3.9.1/bin/pdf2txt.py",line 96,in main
device = HTMLConverter(rsrcmgr,outfp,scale=scale,file "/Users/supreet/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pdfminer/converter.py",line 277,in __init__
self.write_header()
file "/Users/supreet/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pdfminer/converter.py",line 289,in write_header
self.write('<HTML><head>\n')
file "/Users/supreet/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pdfminer/converter.py",line 285,in write
self.outfp.write(text)
TypeError: write() argument must be str,not bytes
请帮帮我,因为我正在尝试的任何 pdf 都会发生这种情况
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的pypdf2 命令将 pdf 转换为 html 失败并出现 TypeError:write() 参数必须是 str,而不是字节,pdfminer,全部内容,希望文章能够帮你解决pypdf2 命令将 pdf 转换为 html 失败并出现 TypeError:write() 参数必须是 str,而不是字节,pdfminer,所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。