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

1. Machine type

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

Machine type

2. Computer’s name

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

Computer’s name

3. System OS

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

4. Processor name

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

5. Python version

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

6. System’s release

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

Release information

7. Return all the 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

Conclusion

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

Happy coding!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store