Python 官方文档:入门教程 => 点击学习
参考网址 首先下载python需要的库 pip install pypiwin32 简单例子 import tempfile import win32api import win32print filename = tempf
参考网址
首先下载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指令打印指定文件。
--结束END--
本文标题: windows下如何用python控制打
本文链接: https://www.lsjlt.com/news/188227.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0