How to check if OS is Vista in Python?

前端 未结 5 1187
眼角桃花
眼角桃花 2020-12-08 10:12

How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython?

Essentially, I need a function that called

5条回答
  •  离开以前
    2020-12-08 11:10

    Python has the lovely 'platform' module to help you out.

    >>> import platform
    >>> platform.win32_ver()
    ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free')
    >>> platform.system()
    'Windows'
    >>> platform.version()
    '5.1.2600'
    >>> platform.release()
    'XP'
    

    NOTE: As mentioned in the comments proper values may not be returned when using older versions of python.

提交回复
热议问题