用于检测Linux发行版的Python模块

Iva*_*ick 4 python redhat suse

是否有一个现有的python模块可用于检测Linux的哪个版本以及当前安装的版本的发行版.

例如:

  • RedHat Enterprise 5
  • Fedora 11
  • Suse Enterprise 11
  • 等等....

我可以通过解析像/ etc/redhat-release这样的各种文件来创建自己的模块,但我想知道模块是否已经存在?

干杯,伊万

Ant*_* P. 16

查找平台模块的文档:http://docs.python.org/library/platform.html

例:

>>> platform.uname()
('Linux', 'localhost', '2.6.31.5-desktop-1mnb', '#1 SMP Fri Oct 23 00:05:22 EDT 2009', 'x86_64', 'AMD Athlon(tm) 64 X2 Dual Core Processor 3600+')
>>> platform.linux_distribution()
('Mandriva Linux', '2010.0', 'Official')

  • 这两个函数都已弃用 (2认同)