1

我在 openerp7 中使用此代码直接从打印机打印此代码是我在 main.py 中编写的,但是当我启动服务器时,它在我的浏览器控制台上给出了未处理的错误,实际上这个错误发生在导入 win32print 模块时。

import win32print
printer=OpenPrinter(win32print.GetDefaultPrinter())
hJob = win32print.StartDocPrinter (printer, 1, ("RVGI Print", None, "RAW"))
g=open('test3.txt','r')
raw_data = bytes ( open( 'test3.txt' , 'r').read ())
try:
    win32print.StartPagePrinter (printer)
    win32print.WritePrinter (printer, raw_data)
    win32print.EndPagePrinter (printer)
finally:
    win32print.EndDocPrinter (printer)
    win32print.ClosePrinter (printer)
4

1 回答 1

2

查看您的代码后,我发现唯一的问题是undefined variable OpenPrinter只需将 OpenPrinter() 替换为win32print.OpenPrinter()

于 2013-02-23T16:33:10.570 回答