How to check if OS is Vista in Python?

前端 未结 5 1197
眼角桃花
眼角桃花 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 10:58

    The solution used in Twisted, which doesn't need pywin32:

    def isVista():
        if getattr(sys, "getwindowsversion", None) is not None:
            return sys.getwindowsversion()[0] == 6
        else:
            return False
    

    Note that it will also match Windows Server 2008.

提交回复
热议问题