To get information about the operating system, on which our code is executed, we can use the “platform” module.
system
The system() method of this moduel returns the text name of the operating system:
1 2 3 4 5 |
import platform print(platform.system()) # Windows |
release
The release() method returns the release number or the text name of the current OS release:
1 2 3 4 5 6 |
import platform print(platform.release()) # 10 # Vista |
platform
The platform() method returns the string with a more detailed OS description:
1 2 3 4 5 |
import platform print(platform.platform()) # Windows-10-10.0.19042-SP0 |
version
The version() method returns the version of the current OS:
1 2 3 4 5 |
import platform print(platform.version()) # 10.0.19042 |
architecture
The architecture() method returns the tuple with the architecture of the current operating system:
1 2 3 4 5 |
import platform print(platform.architecture()) # ('64bit', 'WindowsPE') |