Python 打印到 /dev/usb/lp0
Python print to /dev/usb/lp0
我想从我的 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")
我想从我的 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")