Python development _platform_ Get operating system Details tool

Source: Internet
Author: User

"In Python,PlatformThe module provides us with a number of ways to obtain information about the operating system such as: Import Platform Platform.platform () #获取操作系统名称及版本号, ' Windows-7-6.1.7601-sp1 '        Platform.version () #获取操作系统版本号, ' 6.1.7601 ' platform.architecture () #获取操作系统的位数, (' 32bit ', ' WindowsPE ') Platform.machine () #计算机类型, ' x86 ' Platform.node () #计算机的网络名称, ' hongjie-pc ' platform.processor () #计算机处 Manager information, ' x86 Family 6 stepping 3, AUTHENTICAMD ' Platform.uname () #包含上面所有的信息汇总, Uname_result (system= ' Windo WS ', node= ' hongjie-pc ', release= ' 7 ', version= ' 6.1.7601 ', machine= ' x86 ', processor= ' x86 famil        Y Model 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_im Plementation () platform.python_revision () platform.python_version () platform.python_version_tuple () " ‘

Here is the demo I made:

Operating effect:

=======================================================

Code section:

=======================================================

  1 #python Platform 2 3 #Author: Hongten 4 #Mailto: [email protected] 5 #Blog: HTTP://WWW.CNBL Ogs.com/hongten 6 #QQ: 648719819 7 #Version: 1.0 8 #Create: 2013-08-28 9 Import Platform 11 12 In Python, the Platform module provides us with a number of ways to get information about the operating system 14 such as: Import Platform Platform.platform () #获 Take the operating system name and version number, ' Windows-7-6.1.7601-sp1 ' platform.version () #获取操作系统版本号, ' 6.1.7601 ' platform.architectu Re () #获取操作系统的位数, (' 32bit ', ' WindowsPE ') platform.machine () #计算机类型, ' x86 ' Platform.node () #计         Computer network name, ' hongjie-pc ' platform.processor () #计算机处理器信息, ' x86 Family Model 6 Stepping 3, AUTHENTICAMD ' 22 Platform.uname () #包含上面所有的信息汇总, Uname_result (system= ' Windows ', node= ' hongjie-pc ', 23°c  Elease= ' 7 ', version= ' 6.1.7601 ', machine= ' x86 ', processor= ' x86 Family-Model 6 Stepping 3, AUTHENTICAMD ') 25 26 You can also get some information about Python in your computer: Import platform Platform.python_build () Platform.python_c Ompiler () Platform.python_branch () to Platform.python_implementation () + Platform.python_revis Ion () Platform.python_version () platform.python_version_tuple () "#global var #是否显示日志 Information Show_log = True get_platform def (): 42 "Get the operating system name and version number" "Return Platform.platform () the Def GE  T_version (): 46 "Get OS version number" "Platform.version" () get_architecture (): 50 "Get the number of operating system bits" Wuyi return Platform.architecture () Get_machine (): 54 "Computer Type" "Return Platform.machine () 56 5      7 def Get_node (): 58 "Computer Network Name" "Platform.node" () Max def get_processor (): 62 "Computer Processor info" 63  return Platform.processor () + def Get_system (): 66 "Get operating system type '" Platform.system return () Get_uname (): 70 "Summary information "Platform.uname return" () Get_python_build def (): "The Python build number and date as Strin GS ' ' Platform.python_build return ' () Get_python_compiler (): "Returns A string identifying the C Ompiler used for compiling Python "return Platform.python_compiler () + Bayi def get_python_branch ():" A " Turns a string identifying the Python implementation SCM Branch "' The Return Platform.python_branch () + def get_p Ython_implementation (): Returns A string identifying the Python implementation. Possible return values are: ' CPython ', ' IronPython ', ' Jython ', ' pypy '. Platform.python_implementation return () Get_python_version def (): "Returns the python version as St     Ring ' Major.minor.patchlevel ' Platform.python_version () 94 def get_python_revision (): 95 ' Returns a string identifying the Python implementation SCM revision. ' Platform.python return_revision () 98 def get_python_version_tuple (): "Returns the Python version as tuple (major, minor, Patchlevel ) of Strings "" Platform.python_version_tuple () 101 102 def Show_python_all_info (): 103 "Print all the information of Python" ' 104 print (' The Python build number and date as strings: [{}] '. Format (Get_python_build ())) "Print (' Returns a St Ring identifying the compiler used for compiling Python: [{}] '. Format (Get_python_compiler ())) 106 print (' Returns a str ing identifying the Python implementation SCM Branch: [{}] '. Format (Get_python_branch ())) 107 print (' Returns a string I Dentifying the Python implementation: [{}] '. Format (Get_python_implementation ())) 108 print (' The version of Python: [{ }] '. Format (Get_python_version ())) 109 print (' Python implementation SCM revision: [{}] '. Format (get_python_revision ())     ) Print (' Python version as tuple: [{}] '. Format (Get_python_version_tuple ())) 111 Show_python_info (): 113 "' Print only Python information, no explanation section ' 1Print (Get_python_build ()) (Get_python_compiler ()) print (Get_python_branch ()) 117 print (get_py Thon_implementation ()) 118 print (Get_python_version ()) 119 print (Get_python_revision ()) + print (get_python_vers Ion_tuple ()) 121 122 def show_os_all_info (): 123 "Print all information about the OS ' 124 print (' Get operating system name and version number: [{}] '. Format (Get_platform (     )) (' Get OS version number: [{}] '. Format (get_version ())) 126 print (' Get the number of bits of the operating system: [{}] '. Format (Get_architecture ())) 127 Print (' computer type: [{}] '. Format (Get_machine ()) ' Print (' Network name for computer: [{}] '. Format (Get_node ())) 129 print (' Computer processor information : [{}] '. Format (Get_processor ())) (' Get OS type: [{}] '. Format (Get_system ())) 131 Print (' summary info: [{}] '. Format (GE T_uname ())) 133 Def show_os_info (): 134 "Only print OS information, no explanation part ' 135 print (Get_platform ()) 136 Print (Get_version (     )) 137 print (Get_architecture ()) 138 print (Get_machine ()) 139 Print (Get_node ()) print (Get_processor ()) 141 Print (Get_system ()) 1Print (Get_uname ()) 143 144 def test (): 145 print (' Operating System Information: ') 146 if show_log:147 Show_os_all_info         () 148 else:149 show_os_info () print (' # ' *) 151 print (' Python information on computer: ') if show_log:153 Show_python_all_info () 154 else:155 Show_python_info () 156 157 def init (): 158 Global show_log159 SH Ow_log = True160 161 def main (): 162 init () 163 test () 164 165 if __name__ = = ' __main__ ': 166 Main ()

Python development _platform_ Get operating system Details tool

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.