Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the system is Debian or CentOS in Python?

I want to write some install scripts by python, it should know the OS to choose either apt command or yum command.

It seems sys.platform can tell 'win32' or the others, but how to know it is working on Debian or CentOS in Python?

like image 426
William Avatar asked May 10 '11 14:05

William


1 Answers

The platform module in the standard library has what you want.

import platform
print platform.linux_distribution()
like image 152
Joe Kington Avatar answered Sep 24 '22 18:09

Joe Kington