Python daily Class (2): Platform

Source: Internet
Author: User

According to the Official document explanation (Https://docs.python.org/3.5/library/platform.html#module-platform):

The code for learning other people is as follows:

#Python platform#Author:hongten#Mailto: [email protected]#Blog:http://www.cnblogs.com/hongten#qq:648719819#version:1.0#create:2013-08-28ImportPlatform" "    In Python, the platform module gives us a lot of ways to get information about the operating system such as: Import Platform Platform.platform () #获取操作系统名称及版本号, ' Window  S-7-6.1.7601-sp1 ' Platform.version () #获取操作系统版本号, ' 6.1.7601 ' platform.architecture () #获取操作系统的位数, (' 32bit ', ' WindowsPE ') platform.machine () #计算机类型, ' x86 ' Platform.node () #计算机的网络名称, ' hongjie-pc ' platfor M.processor () #计算机处理器信息, ' x86 Family Model 6 Stepping 3, AUTHENTICAMD ' Platform.uname () #包含上面所有的信息汇总, uname_ Result (system= ' Windows ', node= ' hongjie-pc ', release= ' 7 ', version= ' 6.1.7601 ', machine= ' x86 ',        Processor= ' x86 Family 6 stepping 3, AUTHENTICAMD ') You can also get some information about Python in your computer:        Import Platform Platform.python_build () Platform.python_compiler () Platform.python_branch () Platform.python_implementation () platform.python_revision () platform.python_version () Platform.pyth On_version_tuple ()" "#Global Var#whether to display log informationShow_log =Truedefget_platform ():" "get the operating system name and version number" "    returnPlatform.platform ()defget_version ():" "get the operating system version number" "    returnplatform.version ()defget_architecture ():" "get the number of bits in the operating system" "    returnplatform.architecture ()defget_machine ():" "Computer Type" "    returnPlatform.machine ()defGet_node ():" "the network name of the computer" "    returnPlatform.node ()defget_processor ():" "Computer processor Information" "    returnplatform.processor ()defGet_system ():" "get operating system type" "    returnPlatform.system ()defget_uname ():" "Summary Information" "    returnPlatform.uname ()defget_python_build ():" "The Python build number and date as strings" "    returnPlatform.python_build ()defGet_python_compiler ():" "Returns A string identifying the compiler used for compiling Python" "    returnPlatform.python_compiler ()defget_python_branch ():" "Returns A string identifying the Python implementation SCM Branch" "    returnPlatform.python_branch ()defget_python_implementation ():" "Returns A string identifying the Python implementation. Possible return values are: ' CPython ', ' IronPython ', ' Jython ', ' pypy '." "    returnplatform.python_implementation ()defget_python_version ():" "Returns the Python version as String ' Major.minor.patchlevel '" "    returnplatform.python_version ()defget_python_revision ():" "Returns A string identifying the Python implementation SCM revision." "    returnplatform.python_revision ()defget_python_version_tuple ():" "Returns the Python version as tuple (major, minor, patchlevel) of strings" "    returnplatform.python_version_tuple ()defshow_python_all_info ():" "Print all of Python's information" "    Print('The Python build number and date as strings: [{}]'. Format (Get_python_build ()))Print('Returns A string identifying the compiler used for compiling Python: [{}]'. Format (Get_python_compiler ()))Print('Returns A string identifying the Python implementation SCM Branch: [{}]'. Format (Get_python_branch ()))Print('Returns A string identifying the Python implementation: [{}]'. Format (Get_python_implementation ()))Print('The version of Python: [{}]'. Format (Get_python_version ()))Print('Python Implementation SCM revision: [{}]'. Format (Get_python_revision ()))Print('Python version as tuple: [{}]'. Format (Get_python_version_tuple ()))defshow_python_info ():" "Print only Python information, no explanation part" "    Print(Get_python_build ())Print(Get_python_compiler ())Print(Get_python_branch ())Print(Get_python_implementation ())Print(Get_python_version ())Print(Get_python_revision ())Print(Get_python_version_tuple ())defshow_os_all_info ():" "Print all information about the OS" "    Print('get the operating system name and version number: [{}]'. Format (Get_platform ()))Print('get operating system version number: [{}]'. Format (get_version ()))Print('get the number of bits of the operating system: [{}]'. Format (Get_architecture ()))Print('computer type: [{}]'. Format (Get_machine ()))Print('Computer's network name: [{}]'. Format (Get_node ()))Print('Computer processor information: [{}]'. Format (Get_processor ()))Print('get operating system type: [{}]'. Format (Get_system ()))Print('summary information: [{}]'. Format (Get_uname ()))defshow_os_info ():" "Print only OS information, no explanation section" "    Print(Get_platform ())Print(Get_version ())Print(Get_architecture ())Print(Get_machine ())Print(Get_node ())Print(Get_processor ())Print(Get_system ())Print(Get_uname ())defTest ():Print('Operating System Information:')    ifShow_log:show_os_all_info ()Else: Show_os_info ()Print('#'* 50)    Print('python information in the computer:')    ifShow_log:show_python_all_info ()Else: Show_python_info ()definit ():GlobalShow_log Show_log=TruedefMain (): Init () test ()if __name__=='__main__': Main ()

Python daily Class (2): Platform

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.