문제

I have a problem when I use this code to count the number of pages in pdf file :

if j[i].rstrip() == "Page" or j[i].rstrip() == "page":
            rxcountpages = re.compile(r"/Type\s*/Page([^s]|$)", re.MULTILINE|re.DOTALL)
            data = file("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb")

            print len(rxcountpages.findall(data))

the error is:

Traceback (most recent call last): File "pdf_scanner.py", line 89, in

main()

File "pdf_scanner.py", line 72, in main

print len(rxcountpages.findall(data))

TypeError: expected string or buffer

can an one help me with it?

도움이 되었습니까?

해결책

you have to read the contents of the file:

data = open("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb").read()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top