Python 3.x TypeError:/:';列表';和';int',从pdf中提取表内容时
我想从pdf文件中提取表和内容,并根据新行显示在字符串列表中,但在对行进行样条处理时,会显示type error。我在哪里犯错Python 3.x TypeError:/:';列表';和';int',从pdf中提取表内容时,python-3.x,Python 3.x,我想从pdf文件中提取表和内容,并根据新行显示在字符串列表中,但在对行进行样条处理时,会显示type error。我在哪里犯错 import numpy import PyPDF2 fd = open('./sample2.pdf', 'rb') pdfreader = PyPDF2.PdfFileReader(fd) page = pdfreader.getPage(1) content = page.extractText() tableList = content.split('\n')
import numpy
import PyPDF2
fd = open('./sample2.pdf', 'rb')
pdfreader = PyPDF2.PdfFileReader(fd)
page = pdfreader.getPage(1)
content = page.extractText()
tableList = content.split('\n')
#table has four columns
lines = numpy.array_split(tableList, len(tableList/4))
# displaying row by row
for i in range(0,5):
print(lines[i])
您正在将列表
tableList
除以4
,替换此行:
lines = numpy.array_split(tableList, len(tableList/4))
据此:
lines = numpy.array_split(tableList, len(tableList)/4)
谢谢你,希腊文先生,我可以解决这个问题。这将给你一个浮动而不是一个int@DeveshKumarSinghnumpy将其转换为int。