我已将热敏打印机通过LAN电缆连接到路由器,现在我可以使用它通过python代码在同一网络上的计算机上通过计算机进行打印了,如何在上传到我的站点时使该代码正常工作?
我上传了代码,但只看到我的本地主机而不是打印机ip
例如
from escposprinter import printer
from escposprinter.escpos import EscposIO, Escpos
#works only on local host
printerAddress = '192.168.1.116'
printerPort = 9100
def checkPrinterAlive():
if (printer.Network.isAlive(printerAddress, printerPort)):
return True
else:
raise Exception ("Host is unreachable, socket communication was not opened")
if (checkPrinterAlive()):
with EscposIO(printer.Network(printerAddress, printerPort)) as p:
p.set(font='a', codepage='cp1251', size='normal', align='center', bold=True)
p.writelines('LOGO')
p.printer.nvRamImage()