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.