我在哪里可以找到pycups模块用于CUPS打印的文档?



我使用python cups模块列出可用的目的地。一切都很完美。我已经使用sudo apt-get install pycups安装了pycups

import cups
conn = cups.Connection()
printers = conn.getPrinters()
for p in printers:
print(p)
print(printers[p],["device-uri"])
问题是我没有找到文档对于这个模块,有哪些方法可以用来实现其他的功能。

你知道我在哪里可以找到文档吗?

我遇到了同样的问题。在他们的github中有一个例子,这是我能找到的全部。你可能应该用python调试器来了解这个库是如何工作的。

您可以在python解释器中使用内置的help函数:

>>> import cups
>>> help(cups)
# shows auto-generated documentation for cups module

您可以使用上述答案中提到的内置帮助功能。下面是一个使用pycups

打印文件的示例
|  printFile(...)
|      printFile(printer, filename, title, options) -> integer
|      
|      Print a file.
|      
|      @type printer: string
|      @param printer: queue name
|      @type filename: string
|      @param filename: local file path to the document
|      @type title: string
|      @param title: title of the print job
|      @type options: dict
|      @param options: dict of options
|      @return: job ID
|      @raise IPPError: IPP problem

printFile需要四个参数。我传递了一个空字典,因为这是必要的,而且我正在使用第一台可用的打印机

import cups
conn = cups.Connection ()
printers = conn.getPrinters ()
# printers is a dictionary containing information about all the printers available
emptyDict = {}
AvailablePrinters = list(printers.keys())
PrinterUsing = AvailablePrinters[0]
conn.printFile(PrinterUsing, "./FileName", "title", emptyDict)

最新更新