发布时间:2019-09-06 08:51:59编辑:auto阅读(2214)
参考网址
首先下载python需要的库
pip install pypiwin32
简单例子
import tempfile
import win32api
import win32print
filename = tempfile.mktemp (".txt")
open (filename, "w").write ("This is a test")
win32api.ShellExecute (
0,
"print",
filename,
#
# If this is None, the default printer will
# be used anyway.
#
'/d:"%s"' % win32print.GetDefaultPrinter (),
".",
0
)
但实际上这只是打印自己制定的字符串, 并且打印出来会显示txt的文件名。所以我更倾向于使用windows的cmd指令打印指定文件。
上一篇: 基于python实现日志收集
下一篇: python+opencv实现目标跟踪
51955
51750
42046
38885
33377
30342
28986
24002
23917
22276
460°
2634°
3328°
2756°
2740°
3510°
2702°
3533°
5826°
5611°