Python将png文件发送到默认打印机

时间:2017-08-07 19:18:06

标签: python image png

我有一台热敏打印机,我很想在收据的顶部打印一个徽标...是否有像png图像的shutil.copyfile这样的东西?

我的代码如下

   locations = ['/dev/usb/lp0', '/dev/usb/lp1', '/dev/usb/lp2']
        size = locations.__len__()
        i = 0

        while i < size:
            printer = locations[i]
            try:
                shutil.copyfile('output.txt', printer)
                break
            except IOError:
                i += 1

        if i == size:
            logging.error('Unable to connect to the printer')

1 个答案:

答案 0 :(得分:0)

这是我能够找到的解决方案,感谢thebjorn

>>> r = list(x for x in range(10))
>>> print(5 in r)
True
>>> print(3 in r)
True

谢谢大家。

相关问题