Python Glossary Русский

all Python 3macOSplatformfunction

platform.mac_ver()

specific operating systems

The macOS version as a (release, versioninfo, machine) tuple, e.g. ('14.4.1', ('', '', ''), 'arm64'); empty strings on other OSes.

Syntax

release, versioninfo, machine = platform.mac_ver(release='', versioninfo=('', '', ''), machine='')

This is where the familiar macOS version comes from, since release() on a Mac returns the Darwin kernel version ('23.4.0'). The middle item is a nested tuple that is almost always empty in practice. On Linux and Windows it does not fail but returns the defaults, so test release for emptiness.

Examples

import platform
release, versioninfo, machine = platform.mac_ver()
print(len(versioninfo))  # → 3
print(release)  # → ? на macOS, например 14.4.1; на других ОС пустая строка

See also

Open in the full glossarydocs.python.orgReport an inaccuracy