Social Icons

Tuesday, October 6, 2020

Python Plateforme module
Python-courses-python-modules

1 - About the platform module

Python provides a built-in module called platform to provide various system information. The Platform module is used to retrieve as much information as possible about the platform on which the program is currently running.This module plays a crucial role when you want to check if your program is compatible with the python version installed on a particular system. or whether the hardware specifications meet your program requirements. This module already exists in the python library and does not require installation using the pip utility. It can be imported using the following syntax:
import platform

2 - Methods associated with the platform module

2.1 - The platform.processor() method

Example: display processor informations

# import of the platform module
import platform
# display of processor information
print ('Processor:', platform.processor ())
# The output is: Processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel

2.2 - platform.platform ()

Returns a unique string identifying the underlying platform with as much useful information as possible.

Example

# import of the platform module
import platform
# display of the machine type
print ('Platform processor:', platform.platform ())
# Displays: Platform processor: Windows-7-6.1.7601-SP1

2.3 The platform.architecture() method

This function returns a tuple that stores information about the binary architecture (number of bits in the platform processor) and the binding format.

Example: display of the architecture of the machine

# import of the platform module
import platform
# display of the platform architecture
print ('Platform architecture:', platform.architecture ())
# Displays: Platform architecture: ('64bit', 'WindowsPE')

2.4 - The platform.machine() method

This function returns a string that displays the machine type, by machine type here, this means information that indicates the width or size of the registers available in the kernel.

Example: display of the machine type

# import of the platform module
import platform
# display of the machine type
print ('Machine type:', platform.machine ())
# Displays: Machine type: AMD64

2.5 - The platform.node() method

This function returns a string that displays information about the node, essentially the name of the machine within the network.

Example: display the name of the network node

# coding: utf-8
# import of the platform module
import platform
# node information
print ('Name of the node within the network:', platform.node ())
# Displays: Name of the node within the network: acer-PC

2.6 - platform.system()

This function returns a string that displays the name of the operating system on the current device used to run the program.

Example: display of the name of the operating system

# coding: utf-8
# import of the platform module
import platform
# operating system name
print ('System:', platform.system ())
# Displays: System: Windows

2.7 - The platform.platform() method

This function returns a single string containing as much useful information as possible to retrieve from the system. The output may differ from system to system.

Example: display information on the platform

# import of the platform module
import platform
# display information on the platform
print ('Platform information:', platform.platform ())
# Displays: Platform Info :: Windows-7-6.1.7601-SP1

2.8 - The platform.python_build() method

This function returns a tuple which stores information about python build date and build number. This information is stored in the tuple as a string data type.

Example: Display python version.

# coding: utf-8
# import of the platform module
import platform
# display the python build number
print ('Python build number and date:', platform.python_build())
# Displays: Python build number and date: ('tags / v3.7.2: 9a3ffc0492', 'Dec 23 2018 23:09:28')

2.9 - The platform.uname() method

Quite portable uname interface. Returns a tuple of strings (system, node, version, version, machine, processor) identifying the underlying platform. Note that unlike the os.uname() function, this also returns possible processor information as an additional tuple input.

Example

# import of the platform module
import platform
print ('Platform info:', platform.uname())
# The output is:
#Plate forme info: uname_result(system='Windows', node='acer-PC', release='7', version='6.1.7601', machine='AMD64', processor='Intel64 Family 6 Model 58 Stepping 9,GenuineIntel')

2.10 - platform.python_version ()

This function returns a string that displays the version of Python currently running on the system.

Example: Display of the python version

# Python program to display the python version
# import of the platform module
import platform
# display the python version
print ('Python version:', platform.python_version ())
# Displays: Python version: 3.7.2

2.11 - platform.python_compiler()

This method returns a string identifying the compiler used to compile Python.

Example: Displaying information from the python compiler

# import of the platform module
import platform
# display of the python compiler
print ('Python compiler:', platform.python_compiler ())
# Displays: Python compiler: MSC v.1916 64 bit (AMD64)

2.12 - The platform.python_branch() method

This function returns a string displaying information about the python SCM branch, SCM stands for Source Code Manager, it is a tool used by programmers to manage source code. SCM is used to track software revisions.

Example: Display of python SCM information

# Python program to display python SCM information
# import of the platform module
import platform
# display of python SCM information
print ('Python MSC:', platform.python_compiler ())
# Displays: Python SCM: MSC v.1916 64 bit (AMD64)

2.13 - The platform.python_implementation() method

This function returns a string that displays information about the python implementation. The possible outputs of this function are CPython, JPython, PyPy, IronPython.

Example: Viewing the python implementation

# coding: utf-8
# Python program to show the python implementation
# import of the platform module
import platform
# display the python implementation
print ('Python implementation:', platform.python_implementation ())
# Displays: Python implementation: CPython


Younes Derfoufi
my-courses.net

No comments:

Post a Comment

Category Of Mobile Courses

Actualités (644) Adsense (1) Affiliation (1) Algebraic Topology (2) Algorithmic (1) all-news (30) Android (5) Android App (8) Android app without code (4) Android Apps (205) Android Development (4) Android download (2) Android OS (3) AngularJS (1) Automata theory and formal language (5) C programming (5) Category and Functor (8) CMS (3) Computer Glossary (18) Create Mobile App With Ionic Framework (2) CSS (2) CSS-Cascading-Style-Sheets (4) Developpement Java (13) Differential Geometry (1) Django-Python-Framework (8) dropshiping (26) Earn Money by Internet (4) Emplois (23) Framework php (2) Fraud (2) HTML (7) Java For Beginners (10) Javascript (12) Kotlin Programming Language (8) Kotlin For Mobile Android (1) Linux Download (2) Marketing (5) Mobile (3) Mobile Courses (4) Mobile Marketing (4) MoneyGram (1) News (721) Node.js (5) Open Source (1) Photoshop (1) Protect Computer (1) Python (35) Python BeautifulSoup (1) Python For Data Science (2) Python-Books (6) Python-DVD-Training (1) Python-Exercises (186) Python-Framework (1) Python-IDE (1) Python-Modules (1) Python-pdf (2) Python-pyQt (1) Référencement (2) Script PHP (2) Security (6) SEO (1) Snipping Tool: Faq (1) Social Networks (1) Source Code (1) Statistics With SPSS (2) Surveillance Software (1) Travail à domicile (6) Tutoriels php en vidéos (2) Tutoriels-MySql (6) tutoriels-php (19) Utilitaires (1) VPS (1) Web Hosting (1) Webcam (1) Webmarketing (11) Western Union (1) Windows 10 (1) Windows 7 (4) Windows 7 Faq (2) Windows 8 (1) Windows Accessories (1) Windows Download (8) Windows Drivers (1) Windows Fonts (1) Windows Power Shell (2) Windows Registry (2) Windows Security (18) Windows Software (2) Windows Spyware (2) Windows utilities (3) Windows Virus (2) Windows Vista (3) Windows Wireless (1) Windows xp (1) Wordpress (1)
 

Sample text

Sample Text

 
Blogger Templates