发布时间:2019-09-06 08:51:59编辑:auto阅读(1874)
参考网址
首先下载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实现目标跟踪
48864
47930
38706
35857
30284
27036
26069
20901
20697
19065
498°
593°
603°
605°
584°
570°
633°
709°
827°
928°