The platform
module in Python provides functions that access information of the underlying platform (operating system).
The platform.platform()
method returns a single string containing as much information about the underlying platform as feasible. The output is meant to be viewable by humans rather than machines.
platform(aliased=0, terse=0)
aliased
: Setting this parameter to True
indicates the function to use aliases for different platforms than their common names. For example, SunOS will be reported as Solaris.terse
: Setting this parameter to True
will make the function return minimal information about the platform.This method returns the human readable single string about the underlying platform.
Let’s look at the code below:
import platformplat_str = platform.platform()print("platform.platform() = %s" % (plat_str))min_plat_str = platform.platform(terse=1)print("platform.platform(terse=1) = %s" % (min_plat_str))
platform.platform()
method.platform.platform(terse=1)
method with the terse
parameter as True
is printed.When we enable the terse
parameter, it prints minimal information about the platform in the output.