我想从我的python代码打印到/dev/usb/lp0
。在bash
中,它非常简单:echo 'apple' >/dev/usb/lp0
我找到了linemode,但这不起作用。当我尝试安装它时,出现这些错误。
byte-compiling build/bdist.linux-x86_64/egg/linemode/renderers/xml.py to xml.pyc
File "build/bdist.linux-x86_64/egg/linemode/renderers/xml.py", line 67
def __init__(self, source, *, max_width=None, prelude=True):
^
SyntaxError: invalid syntax
如何从python代码打印到
/dev/usb/lp0
? 最佳答案
这正在工作:
with open('/dev/usb/lp0', 'w') as printer:
printer.write("Line 1\n")
printer.write("Line 2\n")