美文网首页
python使用win32api调用打印机

python使用win32api调用打印机

作者: 阿阿潇 | 来源:发表于2020-08-04 15:09 被阅读0次
import win32api
import win32print
win32api.ShellExecute(0, "print", "test.txt", '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)

如果txt打开的默认程序是记事本,可能会报下面的错;
查了很久没查到原因,后来试了doc文件可以打开,于是把txt默认打开程序换成了写字板就ok了
pywintypes.error: (31, 'ShellExecute', 'A device attached to the system is not functioning.')

相关文章

网友评论

      本文标题:python使用win32api调用打印机

      本文链接:https://www.haomeiwen.com/subject/ogddrktx.html