我正在尝试绘制表格以进行调试并查找表格坐标,但是该图从未出现在屏幕上。 Camelot 内置了使用 matplotlib 库绘制表格的函数。我已经为 camelot 下载了所有依赖项,但我似乎无法弄清楚如何让这个数字出现。
tables = camelot.read_pdf('example.pdf', flavor = 'lattice')
print(tables[0].parsing_report)
plt = camelot.plot(tables[0], kind='grid')
plt.show()
我只需要在 .show() 函数之后添加 Tkinter .mainloop() 函数,以保持图形在我关闭它之前。没有它,图形会立即关闭,以便代码可以一直运行。
从已安装的 cli.py 复制 我这样解决了:
#!/usr/bin/python3
import camelot
import matplotlib.pyplot as plt # this to add
tables = camelot.read_pdf('example.pdf', flavor = 'lattice')
print(tables[0].parsing_report)
# was
# plt = camelot.plot(tables[0], kind='grid')
# new
camelot.plot(tables[0], kind='grid')
plt.show()