python需要的单词量_python是一个单词的打印量

我在使用pypdf时遇到了一个问题,当我查找一个特定单词在pdf文件中的次数时。在

在我的代码中,它发现一个单词的次数,但一页只有一次。所以最大值是页数。单词“The”的结果应该是700左右,但是只显示了30(页面的数量是30)。在import PyPDF3

import re

def read_pdf(file,string):

fils = file.split(".")

print(fils[1])

word = string

if fils[1] == "pdf":

pdfFileObj = open(file,"rb")

# open the pdf file

object = PyPDF3.PdfFileReader(file)

# get number of pages

NumPages = object.getNumPages()

# define keyterms

counter = 0

# extract text and do the search

for i in range(NumPages):

PageObj = object.getPage(i)

print("page " + str(i))

Text = PageObj.extractText()

#print(Text)

if word in Text:

print("The word is on this page")

counter += 1

print(word, "exists", counter, "times in the file")

你们能看看我做错了什么,帮我解决吗?在

谢谢:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值