gpt4 book ai didi

python - 用Python通过打印机打开till

转载 作者:太空宇宙 更新时间:2023-11-03 19:10:25 25 4
gpt4 key购买 nike

我有 Epson TM-U220B 网络打印机和钱箱。我正在开发 Python Web 应用程序,我设法通过我的应用程序配置打印机。我的打印机工作正常,我只想在打印票据时打开。我在互联网上找到了一些打开抽屉的代码。

这是代码:

def print_(printer_name, file_path):
preorder = chr(27)+chr(100)+chr(0)
cut_paper = chr(29)+chr(86)+chr(66)+chr(0)

open_till = chr(27)+chr(112)+chr(10)

the_file = open(file_path, "a")
the_file.seek(0)
the_file.write(preorder)
the_file.seek(0,2)
the_file.write(cut_paper)
the_file.write(open_till)
the_file.close()
conn.printFile(printer_name, file_path, md5(file_path), {})

open_till 是不起作用的代码,其他一切都正常

谢谢

最佳答案

您可以使用以下代码打开钱箱

import win32print

def OpenCashDrawer(printerName) :
printerHandler = win32print.OpenPrinter(printerName)
cashDraweOpenCommand = chr(27)+chr(112)+chr(0)+chr(25)+chr(250)
win32print.StartDocPrinter(printerHandler, 1, ('Cash Drawer Open',None,'RAW'))
win32print.WritePrinter( printerHandler, cashDraweOpenCommand)
win32print.EndDocPrinter(printerHandler)
win32print.ClosePrinter(printerHandler)

OpenCashDrawer("YourPrinterName")

关于python - 用Python通过打印机打开till,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13155114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com