发布时间:2019-09-06 08:51:59编辑:auto阅读(2625)
参考网址
首先下载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实现目标跟踪
54519
41307
35856
31382
26278
25973
24491
20077
16064
15491
2445°
2226°
2328°
2443°
2397°
2611°
2563°
2372°
2439°
2409°