我正在關注示例代碼here。作者有一些documentation他列出了一些用於編寫程序的步驟。當我一起運行整個程序時,它運行得很完美,但是當我按照他所做的步驟操作時,我得到一個AttributeError。pdfquery/PyQuery:示例代碼顯示沒有AttributeError但我的...爲什麼?
這裏是我的代碼
pdf = pdfquery.PDFQuery("Aberdeen_2015_1735t.pdf")
pdf.load()
pdf.tree.write("test3.xml", pretty_print=True, encoding="utf-8")
sept = pdf.pq('LTPage[pageid=\'1\'] LTTextLineHorizontal:contains("SEPTEMBER")')
print(sept.text())
x = float(sept.get('x0'))
y = float(sept.get('y0'))
cells = pdf.extract([
('with_parent','LTPage[pageid=\'1\']'),
('cells', 'LTTextLineHorizontal:in_bbox("%s,%s,%s,%s")' % (x, y, x+600, y+20))
])
一切都正常運行,直到它到達「sept.get」它說,「‘PyQuery’對象有沒有屬性‘得到’。」有誰知道爲什麼程序不會遇到這個錯誤,當它運行在一起,但它發生在一段代碼運行?
你能分享PDF文件,我可以試試嗎? –
@MarkNeedham pdf應該是[這裏](http://www.k12.wa.us/safs/rep/enr/1415/14005t.pdf?_sm_au_=iVV1n3T04JRrk2T3)。 – otteheng