前言
批量打印工具,论坛里面都有。主要我懒,不想去下载,正好尝试着用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))
|