python调用打印机需要使用到pywin32库,使用win32api.ShellExecute可以调用默认打开指定文档的程序进行打印
调用默认打印机进行打印

import tempfile import win32api import win32print filename = tempfile.mktemp (".txt")open(filename,"w").write ("This is a test") win32api.ShellExecute (0,"print",#这个参数为open可以调用默认程序打开指定文件,为 filename,## If this is None, the default printer will# be used anyway.#'/d:"%s"'% win32print.GetDefaultPrinter (),".",0)

 

 

 

import tempfile

 

 

 

import win32api
import win32print
filename = tempfile.mktemp (".txt")
open (filename, "w").write ("This is a test")
win32api.ShellExecute (
 0,
 "printto",
 filename,
 '"%s"' % '指定打印机名',
 ".",
 0
)