如何在 Python 3(跨平台)中打印到操作系统的默认打印机? [英] How do I print to the OS's default printer in Python 3 (cross platform)?
问题描述
我有一个 Python 3 脚本,它将对一些富文本文件 (rtf
) 进行一些正则表达式替换,我希望能够在 Windows 上打印出整个目录的文件,Linux 和 Mac.
I have a Python 3 script that is going to be doing some regex substitution on some Rich Text Files (rtf
) and I would like to be able to print out a whole directory's files on Windows, Linux, and Mac.
有没有办法打印到操作系统的默认打印机,使其适用于所有平台?
Is there a way to print to the OS's default printer so that it works in all platforms?
推荐答案
没有跨平台的方式.在 Linux 和 OS X 上,您可以调用 <代码>lpr(1) 通过 subprocess
和 CUPS 将尽可能最好地处理文档转换,但 Windows 是trickier.
There is no cross-platform way. On Linux and OS X you can invoke lpr(1)
via subprocess
and CUPS will handle the document conversion as best as possible, but Windows is trickier.
这篇关于如何在 Python 3(跨平台)中打印到操作系统的默认打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!