Python implementation gets the operating system version information method _python

Source: Internet
Author: User

Recently, I want to increase the extraction of user operating system version information in my Youmoney (http://code.google.com/p/youmoney/). For example, Windows users may want to return to Windows XP or Windows 2003, and Apple users should return to Mac OS X 10.5.8. There are a number of ways, including calling system commands, taking environment variables, and so on in Mac systems. In the end, I didn't realize that there was a platform module inside Python that could do this thing. It's Convenient!

That's what the Mac did.

Copy Code code 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 the more information.
>>> Import Platform
>>> Platform.mac_ver ()
(' 10.5.8 ', (', ', ', '), ' i386 ')
>>> platform.version ()
' Darwin Kernel Version 9.8.0:wed 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 you are 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.