我在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)
答案 0 :(得分:2)
查看代码之后,我只能找到undefined variable OpenPrinter
的问题,只需用win32print.OpenPrinter()