Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x TypeError:/:';列表';和';int',从pdf中提取表内容时_Python 3.x - Fatal编程技术网

Python 3.x TypeError:/:';列表';和';int',从pdf中提取表内容时

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')

我想从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')
#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。