
"The sys module's platform attribute also points to a string: Unlike os.name, this string has many more possible values. When running Python on Linux, as I am, sys.platform will be linux. When running on Windows, sys.platform will be win32. On Mac, it'll be darwin. But there are also other options. For example, there's android, ios, and cygwin. Here are common values for sys.platform: The sys module's platform attribute is a little bit newer than the os module's name attribute: sys.platform was added in Python 1.3."
"In addition to os.name and sys.platform, there's an even higher level approach to find the platform that your code is running on, with the platform module. The platform module was added in Python 2.3. The system function within Python's platform module returns the name of the operating system your code is running on: Notice that the name Linux is capitalized above. These names are meant to be user-facing."
Python code can detect the host operating system using three common approaches: os.name, sys.platform, and platform.system(). os.name returns 'nt' on Windows and 'posix' on most other systems; it is the oldest and least granular method. sys.platform returns more detailed strings such as 'linux', 'win32', 'darwin', 'android', 'ios', or 'cygwin', and was added in Python 1.3. platform.system() returns user-facing names like 'Linux', 'Windows', or 'Darwin'; the platform module was added in Python 2.3 and its system() function provides higher-level, human-readable names with more granularity than os.name.
Read at Pythonmorsels
Unable to calculate read time
Collection
[
|
...
]