我想从我的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
?
答案 0 :(得分:3)
这是有效的:
with open('/dev/usb/lp0', 'w') as printer:
printer.write("Line 1\n")
printer.write("Line 2\n")