发布时间:2019-09-06 08:51:59编辑:auto阅读(2520)
参考网址
首先下载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实现目标跟踪
53750
40583
35006
30734
25601
25374
23809
19290
15404
14902
1471°
1354°
1457°
1491°
1500°
1680°
1638°
1527°
1625°
1578°