Python 批量打印文件
参考地址
安装环境
pip install pypiwin32
单个文件打印栗子
import win32api
import win32print
import os
def printer_loading(filename):
win32api.ShellExecute (
0,
"print",
filename,
'/d:"%s"' % win32print.GetDefaultPrinter (),
".",
0
)
printer_loading(r'D:测试.doc')
多个文件打印
import win32api
import win32print
import os
def printer_loading(filename):
win32api.ShellExecute (
0,
"print",
filename,
'/d:"%s"' % win32print.GetDefaultPrinter (),
".",
0
)
path='D:/文件夹'
for filenames in os.listdir(path):
printer_loading(os.path.join(path,filenames))