


Tutorial on how to use the platform module to obtain system information in Python
Operating system related
- system(): operating system type (see example)
- version(): operating system version
- release(): operating system release number, for example, win 7 returns 7, and NT, 2.2.0, etc.
- platform(aliased=0, terse=0): operating system information string, combined 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 obtain Linux OS release version information. Return (distname, version, id). dist means release version .
- mac_ver(release='', versioninfo=('', '', ''), machine=''): mac version
- java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')): java version
- libc_ver(executable=r'c:Python27python.exe', lib='', version='', chunksize=2048): libc version, Linux related.
The returned tuple of the above corresponding version query corresponds to its formal parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
System Information
- uname(): Returns tuple, system, node, release, version, machine, processor.
- architecture(executable=r'c:Python27python.exe', bits='', linkage=''): System architecture
- machine(): CPU platform, AMD, x86? (see example)
- node(): node name (machine name, such as Hom-T400)
- processor() : CPU information
- system_alias(system, release, version): Returns the corresponding tuple.. Useless.
- platform.architecture()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Python related
- python_version(): py version number
- python_branch(): python branch (subversion information), usually empty.
- python_build(): python compilation number (default) and date.
- python_compiler(): py compiler information
- python_implementation(): python installation implementation method, such as CPython, Jython, Pypy, IronPython (.net), etc.
- python_revision(): python type revision information, usually empty.
- python_version_tuple(): tuple divided by python version number.
- popen(cmd, mode='r', bufsize=None): portable popen() interface, executes various commands.
- python_verison()
1 2 3 4 5 6 7 8 9 10 |
|
Get username:
1 2 3 |
|
Get environment variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
There is also os.environ.get, which will return all environment variables as a dictionary

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

About Pythonasyncio...

Pylance type detection problem solution when using custom decorator In Python programming, decorator is a powerful tool that can be used to add rows...

Loading pickle file in Python 3.6 environment error: ModuleNotFoundError:Nomodulenamed...

Using python in Linux terminal...

Compatibility issues between Python asynchronous libraries In Python, asynchronous programming has become the process of high concurrency and I/O...

The problem and solution of the child process continuing to run when using signals to kill the parent process. In Python programming, after killing the parent process through signals, the child process still...

Error loading Pickle file in Python 3.6 environment: ModuleNotFoundError:Nomodulenamed...
