发布时间:2019-09-06 08:51:59编辑:auto阅读(2486)
参考网址
首先下载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实现目标跟踪
53520
40348
34749
30504
25381
25179
23592
18860
15171
14679
1147°
1069°
1139°
1154°
1189°
1347°
1307°
1279°
1379°
1320°