Operating system related
- System (): Operating system type (see example)
- Version (): Operating system versions
- Release (): Operating system publishing number, such as Win 7 return 7, also like NT, 2.2.0 and so on.
- Platform (Aliased=0, terse=0): Operating system Information string, consignor with System () +win32_ver () [: 3]
- Win32_ver (release= ', version= ', csd= ', Ptype= '): Win system related information
- Linux_distribution (distname= ', version= ', id= ', supported_dists= (' SuSE ', ' debiaare ', ' yellowdog ', ' Gentoo ', '), ' Unitedlinux ', ' turbolinux '), full_distribution_name=1): Linux system related information
- Dist (distname= ', version= ', id= ', supported_dists= (' SuSE ', ' Debian ', ' fedora ', ' redhat ', ' CentOS ', ' Mandrake ', '), ' Mandriva ', ' Rocks ', ' slackware ', ' yellowdog ', ' Gentoo ', ' unitedlinux ', ' turbolinux '): Try to get the Linux OS release information. return (Distname, Version,id). Dist is the meaning of the release version.
- Mac_ver (release= ', versioninfo= (', ', ', '), machine= '): Mac version
- Java_ver (release= ', vendor= ', vminfo= (', ', ', '), osinfo= (', ', ', ')): Java version
- Libc_ver (executable=r ' C:\Python27\python.exe ', lib= ', version= ', chunksize=2048): libc version, Linux related.
The return tuple for the corresponding version of the query corresponds to its formal parameters.
Platform.system ()
' Linux ' # python 3.3.2+, bits on Debian Jessie-bits
' Windows ' # python 3.3.2-bits on win Dows 8.1 bits
' windows ' # python 3.3.2, bits on Windows 8.1, bits
' Darwin ' # python 3.4.1, bits on Mac OS x 10.9.4
' Java '
platform.version ()
' #1 SMP Debian 3.10.11-1 (2013-09-10) ' # python 3.3.2+-bits on Debian j Essie bits
' 6.2.9200 ' # python 3.3.2-bits on Windows 8.1-bits
' 6.2.9200 ' # python 3.3.2-bits on window S 8.1 $
' Darwin Kernel Version 13.3.0:tue June 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/release_x86_64 ' # py Thon 3.4.1 bits on Mac OS X 10.9.4
platform ()
' Windows-7-6.1.7601-sp1 '
win32_ver ()
(' 7 ', ' 6.1.7601 ', ' SP1 ', U ' Multiprocessor free ')
platform.dist ()
(' Debian ', ' jessie/sid ', ') # python 3.3.2+-Bits On Debian Jessie-Bits
System Information
- uname (): Returns tuples, System, node, release, version, machine, processor.
- Architecture (executable=r ' C:\Python27\python.exe ', bits= ', linkage= '): System architecture
- machine (): CPU platform, amd,x86? (see example)
- node (): Nodes name (machine name, such as hom-t400)
- processor (): CPU Information
- System_alias (System, Release, Version): Returns the corresponding tuple ... No He Yi.
- platform.architecture ()
(' 64bit ', ' ELF ') # python 3.3.2+, bits on Debian Jessie-bits (' 32bit ', ' WindowsPE ') # python 2.7.2 bits on window S 7 bits (' 64bit ', ' WindowsPE ') # python 3.3.2, bits on Wndows 8.1 bits (' 64bit ', ') # Python 3.4.1 and bits on MA C OS X 10.9.4 platform.machine () ' x86_64 ' # python 3.3.2+, bits on Debian Jessie $ Bits ' AMD64 ' # python 3.3.2-Bits On Windows 8.1 $ Bits ' AMD64 ' # python 3.3.2 to bits on Windows 8.1 bits ' x86_64 ' # python 3.4.1-bits on Mac OS X 10.9.4 platform.node () ' hom-t400 ' platform.processor () ' Intel64 Family 6 Model stepping ' Genuineintel. Uname () (' Windows ', ' hom-t400 ', ' 7 ', ' 6.1.7601 ', ' AMD64 ', ' Intel64 Family 6 Model stepping, Genuineintel ') uname_re Sult (system= ' Linux ', node= ' work ', release= ' 3.10-3-amd64 ', version= ' #1 SMP Debian 3.10.11-1 (2013-09-10) ', machine= ' x86 _64 ', processor= ') # python 3.3.2+, bits on debian Jessie bits Uname_result (system= ' Windows ', node= ' work-xxx ', rel Ease= ' 8 ', version= ' 6.2.9200 ', machine= ' AMD64 ', processor= ' Intel64 Family 6 Model Stepping 9,genuineintel ') # python 3.3.2-bits on Windows 8.1 64 Bits Uname_result (system= ' Darwin ', node= ' MBA ', release= ' 13.3.0 ', version= ' Darwin Kernel version 13.3.0:tue June 3 21:27 : PDT 2014;
Root:xnu-2422.110.17~1/release_x86_64 ', machine= ' x86_64 ', processor= ' i386 ') # Python 3.4.1, bits on Mac OS X 10.9.4
Python related
- Python_version (): PY version number
- Python_branch (): Python Branch (child version information), generally null.
- Python_build (): Python compilation number (default) and date.
- Python_compiler (): Py compiler information
- Python_implementation (): Python installation fulfillment methods, such as CPython, Jython, PyPy, IronPython (. net).
- Python_revision (): Python type modified version information, generally empty.
- Python_version_tuple ():p the tuple after the Ython version number is split.
- Popen (cmd, mode= ' R ', Bufsize=none): Portable Popen () interface, execute various commands.
- Python_verison ()
' 3.3.2+ ' # python 3.3.2+, bits on Debian Jessie, bits
' 3.3.3 ' # python 3.3.2-bits on Windows 8.1 $ bits
py Thon_version_tuple () (
' 2 ', ' 7 ', ' 2 ')
Python_build ()
(' Default ', ' June 15:08:59 ')
Python_ Compiler ()
' MSC v.1500 bit (Intel) '
pl.python_implementation () '
CPython '
Get User name:
>>> import Getpass
>>> getpass.getuser ()
' root '
To get environment variables:
>>> Import OS
>>> import pwd
>>> os.environ[' LANG ']
' en_US. UTF-8 '
>>> print os.getenv (' LANG ')
en_US. UTF-8
>>> Print os.getenv (' PWD ')
/root
>>> print os.getenv (' home ')
/root
>>> Print os.getenv (' USER ')
root
>>> print os.getenv (' HOSTNAME ')
Localhost.localdomain
>>> Print os.getenv (' SHELL ')
/bin/bash
>>> pwd.getpwuid ( Os.getuid ())
pwd.struct_passwd (pw_name= ' root ', pw_passwd= ' x ', Pw_uid=0, pw_gid=0, pw_gecos= ' root ', pw_dir= '/ Root ', pw_shell= '/bin/bash ')
>>> pwd.getpwuid (Os.getuid ()) [0] #获得用户名
' root '
>>> Pwd.getpwuid (Os.getuid ()) [5] #获得家目录
'/root '
>>> pwd.getpwuid (Os.getuid ()) [6] #获得shell
'/ Bin/bash '
The
also has a os.environ.get that returns all environment variables to a dictionary