提问人:sandakelum priyamantha 提问时间:11/5/2023 更新时间:11/5/2023 访问量:62
如何更改打印机端口 USNIG Win32Print (Python3.11)
how to change printer port usnig win32print (python3.11)
问:
我尝试使用以下代码更改打印机端口
import win32ui
import win32print
import time
printer_name = "XP-80C"
desired_port = "USB001"
# Set the desired port for the printer
p = win32print.OpenPrinter(printer_name)
po = win32print.GetPrinter(p,2)
po['pPortName'] = "USB001"
print(po)
try:
win32print.SetPrinter(p, 2, po,0)
dc = win32ui.CreateDC()
dc.CreatePrinterDC(printer_name)
dc.StartDoc("Print Text")
dc.StartPage()
except Exception as e:
print(e)
但是我收到这个错误,如何解决?(5, 'SetPrinter', 'Access is denied.')
尝试以编程方式更改打印机端口
答: 暂无答案
评论