3

以下代码使用该rpm模块查询已安装包的版本。我想做的是查询由 glob 指定的一组包,例如搜索"python*"而不是"python". 这可以使用rpm模块吗?

  1 #!/usr/bin/python
  2 
  3 import rpm
  4 
  5 ts = rpm.TransactionSet()
  6 mi = ts.dbMatch("name", "python")
  7 for i in mi:
  8     print i['name'], i['version']

`

4

1 回答 1

5
import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
mi.pattern('name', rpm.RPMMIRE_GLOB, 'py*' )
for h in mi:
   # Do something with the header... 
于 2010-07-25T17:36:19.757 回答