OS info in Python – is a simple use case to get hands-on with the Python platform package.
OS info in Python platform:
We can get the OS info in python using the platform
package. The platform package gives a lot more apart from the OS info. Let’s check the details.
import platform as plf
profiles = [
'architecture',
'mac_ver',
'machine',
'node',
'platform',
'processor',
'python_build',
'python_compiler',
'python_version',
'release',
'system',
'uname',
'version',
]
for profile in profiles:
if hasattr(plf, profile):
print(profile+ ": " + str(getattr(plf, profile)()))
As an output, you can see your platform details.
Output:
architecture: ('64bit', 'WindowsPE')
mac_ver: ('', ('', '', ''), '')
machine: AMD64
node: DESKTOP-RN4SMHT
platform: Windows-10-10.0.15063-SP0
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
python_build: ('v3.7.3:ef4ec6ed12', 'Mar 25 2019 22:22:05')
python_compiler: MSC v.1916 64 bit (AMD64)
python_version: 3.7.3
release: 10
system: Windows
uname: uname_result(system='Windows', node='DESKTOP-RN4SMHT', release='10', version='10.0.15063', machine='AMD64', processor='Intel64 Family 6 Model 69 Stepping 1, GenuineIntel')
version: 10.0.15063
Done!
Happy Learning:)