Python implementation gets the operating system version information method

Source: Internet
Author: User
Recently, I want to add the user OS version information in my Youmoney (http://code.google.com/p/youmoney/). For example, Windows users may want to return Windows XP, or Windows 2003, Apple users should return to Mac OS X 10.5.8. There are many ways to do this, including invoking system commands, taking environment variables, and so on in Mac systems. In the end, there is a platform module in Python that can do this thing. Oh, easy!

Doing this on your Mac.

The code is as follows:


localhost:~ apple$ python
Python 2.5.1 (r251:54863, June 17 2009, 20:37:34)
[GCC 4.0.1 (Apple Inc. build 5465)] on Darwin
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Platform
>>> Platform.mac_ver ()
(' 10.5.8 ', (', ', ', '), ' i386 ')
>>> platform.version ()
' Darwin Kernel Version 9.8.0:wed Jul 16:55:01 PDT 2009; Root:xnu-1228.15.4~1/release_i386 '
>>> Platform.platform ()
' Darwin-9.8.0-i386-32bit '
>>> Platform.system ()
' Darwin '
>>>


Basically using Platform.platform () is enough. If it is on Windows, there is a special platform.win32_ver () available.
  • 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.