不幸的是,没有在所有平台上使用Python进行打印的标准方法。因此,您需要编写自己的包装器函数进行打印。
您需要检测程序正在运行的操作系统,然后:
对于Linux-
import subprocesslpr = subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)lpr.stdin.write(your_data_here)对于Windows:http://timgolden.me.uk/python/win32_how_do_i/print.html
更多资源:
使用python的win32print模块打印PDF文档?
如何在Python
3(跨平台)中打印到操作系统的默认打印机?



