Skip to content

Instantly share code, notes, and snippets.

@JasonCrowe
Created September 29, 2017 13:44
Show Gist options
  • Save JasonCrowe/faebf5694c3e48ea69eabeb459bf113e to your computer and use it in GitHub Desktop.
Save JasonCrowe/faebf5694c3e48ea69eabeb459bf113e to your computer and use it in GitHub Desktop.
Printing from python
import tempfile
import win32api
import win32print
filename = tempfile.mktemp (".txt")
open (filename, "w").write (str(df))
win32api.ShellExecute (
0,
"print",
filename,
#
# If this is None, the default printer will
# be used anyway.
#
'/d:"%s"' % win32print.GetDefaultPrinter (),
".",
0
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment