Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

printing - How do I print to the OS's default printer in Python 3 (cross platform)?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...