Text of docs.python.org › id › 3 › library › platform.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

platform --- Access to underlying platform's identifying data — Dokumentasi Python 3.15.2

Navigasi index modul | berikut | sebelum | Python » 3.15.2 documentation » The Python standard library » Layanan Sistem Operasi Generik » platform --- Access to underlying platform's identifying data | Tema | platform --- Access to underlying platform's identifying data ¶ Source code: Lib/platform.py Catatan Specific platforms listed alphabetically, with Linux included in the Unix section. Cross platform ¶ platform. architecture ( executable = sys.executable , bits = '' , linkage = '' ) ¶ Queries the given executable (defaults to the Python interpreter binary) for various architecture information.

Returns a tuple (bits, linkage) which contain information about the bit architecture and the linkage format used for the executable. Both values are returned as strings. Values that cannot be determined are returned as given by the parameter presets. If bits is given as '' , the sizeof(pointer) (or sizeof(long) on Python version < 1.5.2) is used as indicator for the supported pointer size. The function relies on the system's file command to do the actual work.

This is available on most if not all Unix platforms and some non-Unix platforms and then only if the executable points to the Python interpreter. Reasonable defaults are used when the above needs are not met. Catatan On macOS (and perhaps other platforms), executable files may be universal files containing multiple architectures. To get at the "64-bitness" of the current interpreter, it is more reliable to query the sys.maxsize attribute: is_64bits = sys . maxsize > 2 ** 32 platform. machine ( ) ¶ Returns the machine type, e.g. 'AMD64' .

An empty string is returned if the value cannot be determined. The output is platform-dependent and may differ in casing and naming conventions. platform. node ( ) ¶ Returns the computer's network name (may not be fully qualified!). An empty string is returned if the value cannot be determined. platform. platform ( aliased = False , terse = False ) ¶ Returns a single string identifying the underlying platform with as much useful information as possible.

The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If aliased is true, the function will use aliases for various platforms that report system names which differ from their common names, for example SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform.

Berubah pada versi 3.8: On macOS, the function now uses mac_ver() , if it returns a non-empty release string, to get the macOS version rather than the darwin version. platform. processor ( ) ¶ Returns the (real) processor name, e.g. 'amdk6' . An empty string is returned if the value cannot be determined. Note that many platforms do not provide this information or simply return the same value as for machine() . NetBSD does this. platform. python_build ( ) ¶ Returns a tuple (buildno, builddate) stating the Python build number and date as strings. platform. python_compiler ( ) ¶ Returns a string identifying the compiler used for compiling Python. platform. python_branch ( ) ¶ Returns a string identifying the Python implementation SCM branch. platform. python_implementation ( ) ¶ Returns a string identifying the Python implementation.

Possible return values are: 'CPython', 'IronPython', 'Jython', 'PyPy'. platform. python_revision ( ) ¶ Returns a string identifying the Python implementation SCM revision. platform. python_version ( ) ¶ Returns the Python version as string 'major.minor.patchlevel' . Note that unlike the Python sys.version , the returned value will always include the patchlevel (it defaults to 0). platform. python_version_tuple ( ) ¶ Returns the Python version as tuple (major, minor, patchlevel) of strings.

Note that unlike the Python sys.version , the returned value will always include the patchlevel (it defaults to '0' ). platform. release ( ) ¶ Returns the system's release, e.g. '2.2.0' or 'NT' . An empty string is returned if the value cannot be determined. On iOS and Android, this is the user-facing OS release. To obtain the Darwin or Linux kernel release, use os.uname() . platform. system ( ) ¶ Returns the system/OS name, such as 'Linux' , 'Darwin' , 'Java' , 'Windows' .

An empty string is returned if the value cannot be determined. On iOS and Android, this returns the user-facing OS name (i.e, 'iOS , 'iPadOS' or 'Android' ). To obtain the kernel name ( 'Darwin' or 'Linux' ), use os.uname() . platform. system_alias ( system , release , version ) ¶ Returns (system, release, version) aliased to common marketing names used for some systems. It also does some reordering of the information in some cases where it would otherwise cause confusion. platform. version ( ) ¶ Returns the system's release version, e.g. '#3 on degas' .

An empty string is returned if the value cannot be determined. platform. uname ( ) ¶ Fairly portable uname interface. Returns a namedtuple() containing six attributes: system , node , release , version , machine , and processor . processor is resolved late, on demand. Note: the first two attribute names differ from the names presented by os.uname() , where they are named sysname and nodename . Entries which cannot be determined are set to '' .

Berubah pada versi 3.3: Result changed from a tuple to a namedtuple() . Berubah pada versi 3.9: processor is resolved late instead of immediately. platform. invalidate_caches ( ) ¶ Clear out the internal cache of information, such as the uname() . This is typically useful when the platform's node() is changed by an external process and one needs to retrieve the updated value. Added in version 3.14. Windows platform ¶ platform. win32_ver ( release = '' , version = '' , csd = '' , ptype = '' ) ¶ Get additional version information from the Windows Registry and return a tuple (release, version, csd, ptype) referring to OS release, version number, CSD level (service pack) and OS type (multi/single processor).

Values which cannot be determined are set to the defaults given as parameters (which all default to an empty string). As a hint: ptype is 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The 'Free' refers to the OS version being free of debugging code. It could also state 'Checked' which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc. platform. win32_edition ( ) ¶ Returns a string representing the current Windows edition, or None if the value cannot be determined.

Possible values include but are not limited to 'Enterprise' , 'IoTUAP' , 'ServerStandard' , and 'nanoserver' . Added in version 3.8. platform. win32_is_iot ( ) ¶ Return True if the Windows edition returned by win32_edition() is recognized as an IoT edition. Added in version 3.8. macOS platform ¶ platform. mac_ver ( release = '' , versioninfo = ('', '', '') , machine = '' ) ¶ Get macOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version) .

Entries which cannot be determined are set to '' . All tuple entries are strings. iOS platform ¶ platform. ios_ver ( system = '' , release = '' , model = '' , is_simulator = False ) ¶ Get iOS version information and return it as a namedtuple() with the following attributes: system is the OS name; either 'iOS' or 'iPadOS' . release is the iOS version number as a string (e.g., '17.2' ). model is the device model identifier; this will be a string like 'iPhone13,2' for a physical device, or 'iPhone' on a simulator. is_simulator is a boolean describing if the app is running on a simulator or a physical device.

Entries which cannot be determined are set to the defaults given as parameters. Unix platforms ¶ platform. libc_ver ( executable = sys.

The rest of this page is on the live site.