Interpreter information
Platform.python_version (): Returns the Python version string ' Major.minor.patchlevel '. Sys.version has similar functionality, but returns more information.
Platform.python_version_tuple (): Returns the Python version (major, minor, Patchlevel).
Platform.python_build (): Returns the tuple (Buildno, builddate), which is the Python version number and date.
Platform.python_compiler (): Returns a string that describes the compiler that compiled python.
Platform.python_branch (): Returns the description of the compiled Python branch.
Platform.python_implementation (): Returns a Python implementation, such as ' CPython ', ' IronPython ', ' Jython ', ' pypy '.
Platform.python_revision (): Returns the Python patch version number.
The following are the results of Ubuntu 14.04 execution:
>>> import platform>>> platform.python_version () ' 2.7.6 ' >>> import sys>>> Sys.version ' 2.7.6 (default, Mar, 22:59:56) \n[gcc 4.8.2] ' >>> platform.python_version_tuple (' 2 ', ' 7 ', ' 6 ') >>> Platform.python_compiler () ' GCC 4.8.2 ' >>> platform.python_build () (' Default ', ' Mar 22 2014 22:59:56 ') >>> platform.python_implementation () ' CPython ' >>> platform.python_revision () ' > >> Platform.python_branch () "
Platform Information
The output is oriented to the user rather than to the machine and will be different on different platforms.
If aliased is True,sunos will be reported as the alias Solaris, the System_alias function is actually called.
Terse set to true uses the compact mode to display only kernel-related information.
Platform.uname (): Returns a tuple (System, node,release, version, machine , Processor). With Os.uname () , the processor information is added.
- Platform.java_ver (release= ', vendor= ', vminfo= (', ', ' , ' ), osinfo= (', ' , ', ' ) : Returns tuples (release, vendor, Vminfo, osinfo). Vminfo is a tuple (vm_name, vm_release, Vm_vendor). osinfo is a tuple (os_name, os_version, os_arch).
>>> platform.platform () ' Linux-3.13.0-51-generic-x86_64-with-ubuntu-14.04-trusty ' >>> Platform.platform (aliased=true) ' Linux-3.13.0-51-generic-x86_64-with-ubuntu-14.04-trusty ' >>> Platform.platform (terse=true) ' linux-3.13.0-51-generic-x86_64-with-glibc2.4 ' >>> platform.uname (' Linux ', ' andrew-hi-fi-a88s2 ', ' 3.13.0-53-generic ', ' #89-ubuntu SMP Wed may 10:34:39 UTC ', ' x86_64 ', ' x86_64 ' >>> ; Platform.java_ver (' 1.8.0_45 ', ' Oracle Corporation ', (' Java HotSpot (TM) 64-bit Server VM ', ' 25.45-b02 ', ' Oracle Corporation '), (' Linux ', ' 3.13.0-53-generic ', ' AMD64 '))
Operating system and hardware information
Platform.system (): Returns the system/os name, such as ' Linux ', ' Windows ' or ' Java '. Returns an empty string if it cannot be determined.
Platform.system_alias (Systems, release, version): Returns the system alias, such as ' Linux ', ' Windows ' or ' Java '. Returns an empty string if it cannot be determined.
Platform.node (): Returns the network name of the computer (not necessarily complete). Returns an empty string if it cannot be determined.
Platform.release (): Returns the system's release, such as ' 2.2.0 ' or ' NT '. Returns an empty string if it cannot be determined.
Platform.version (): Returns the release version of the system, such as ' #3on Degas '. Returns an empty string if it cannot be determined.
Platform.machine (): Returns the machine type, for example ' 386 '. Returns an empty string if it cannot be determined.
Platform.processor (): Returns the (real) processor name, such as "Amdk6". An empty string is returned. Many platforms do not provide this information, the result of the machine function is returned directly.
- Platform.win32_ver (release= ", version=", csd= ", ptype="): Returns a tuple (release , version, CSD, ptype).
- Platform.mac_ver (release= ", versioninfo= (", ", ", " ), machine=") : Returns the tuple (release, versioninfo,machine). versioninfo for (version, dev_stage,non_release_version).
- Platform.linux_distribution (distname= ", version=", id= ", supported_dists = (' SuSE ', ' Debian ', ' Redhat ', ' Mandrake ', ...), Full_ Distribution_name=1) returns a tuple (distname,version,id).
- Platform.libc_ver (executable=sys.executable, lib= ", version=", chunksize= 2048): Returns the libc version (lib,version).
>>> import platform>>> Platform.system () ' Linux ' >>> platform.node () ' Andrew-hi-fi-a88s2 ' >>> platform.release () ' 3.13.0-51-generic ' >>> platform.version () ' #84-ubuntu SMP Wed Apr 15 12:08:34 UTC >>> platform.machine () ' x86_64 ' >>> platform.processor () ' x86_64 ' >>> Platform.linux_distribution (' Ubuntu ', ' 14.04 ', ' trusty ') >>> platform.libc_ver (' glibc ', ' 2.4 ')
Resources
Python2 Platform English Documents
Author Blog: http://my.oschina.net/u/1433482
Type: Translation plus finishing. This article has referred to some English documents, but in the moment can't remember where, the back up.
Python module Introduction-platform: Underlying platform information-resources to be updated