我正在尝试运行此代码。它给了我以字节为单位的输出。我想知道如何将字节转换为文本文件
def convert(fname,pages):
if not pages:
pagenums = set()
else:
pagenums = set(str(pages))
output = StringIO()
manager = PDFResourceManager()
converter = TextConverter(manager, output, laparams=LAParams())
interpreter = PDFPageInterpreter(manager, converter)
infile = open(fname, 'rb')
for page in PDFPage.get_pages(infile):
interpreter.process_page(page)
infile.close()
converter.close()
text = output.getvalue()
output.close
return text