我正在尝试从一个 txt 文件中的 3000 多个 PDF 中提取文本(而我必须从每一页中删除标题):
for x in range(len(files)-len(files)+15):
pdfFileObj=open(files[x],'rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
for pageNum in range(1,pdfReader.numPages):
pageObj=pdfReader.getPage(pageNum)
content=pageObj.extractText()
removeIndex = content.find('information.') + len('information.')
newContent=content[removeIndex:]
file.write(newContent)
file.close()
但是,我收到以下错误:
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\ufb02' in position 5217: character maps to <undefined>