我正在寻找解决方案,打印网页到本地文件 PDF,使用 Python。一个好的解决方案是使用 Qt,在这里找到 https://bharatikunal.wordpress.com/2010/01/。
由于 PyQt4的安装出现了问题,所以一开始它并不能正常工作,因为它提供了错误消息,比如‘ ImportError: No module named PyQt4.QtCore
’和‘ ImportError: No module named PyQt4.QtCore
’。
这是因为 PyQt4没有正确安装。 我曾经把库放在 C: Python27Lib 上,但是它不适用于 PyQt4。
实际上,它只需要从 http://www.riverbankcomputing.com/software/pyqt/download下载(注意您正在使用的正确的 Python 版本) ,并将其安装到 C: Python27(我的示例)。就是这样。
现在脚本运行良好,所以我想分享它。有关使用 QQ 打印机的更多选项,请参阅 http://qt-project.org/doc/qt-4.8/qprinter.html#Orientation-enum。