Get system information using python

Photo by Possessed Photography on Unsplash

Python provides a built-in module called “platform” that enables us to fetch some of the information about our system such as OS, processor, system version, etc

Let us look at some of the methods one by one with an example for each

The machine() method returns the machine type of the user. An empty string is returned if the value cannot be determined.

Machine type

The node() method returns the computer’s network name. An empty string is returned if the value cannot be determined.

Computer’s name

The platform() method returns a single string identifying the underlying platform with as much useful information as possible.

This can give various information such as the OS, OS version, processor etc all in a single string.

OS information

This processor() method returns the name of the processor used by the system e.g. 'amdk6', 'i386'.

Many platforms do not provide this information and an empty string is returned if the value cannot be determined.

My system uses an Intel i3 processor and hence i386.

Processor information

The python_version() method returns the Python version as a string 'major.minor.patchlevel'.

Note that, unlike the Python sys.version, the returned value will always include the patch level (it defaults to 0).

Python version

The release() method returns the system’s release version. An empty string is returned if the value cannot be determined.

Release information

The uname() method returns all the output of the above methods as a nameduple.

The six attributes returned by this method are

  1. system
  2. node
  3. release
  4. version
  5. machine
  6. processor
All information

Hope this article was helpful. Follow me for more cool articles on python.

Happy coding!

Python Developer | Django Developer | Python Enthusiast