what is better way of getting windows version in python?

前端 未结 2 1447
太阳男子
太阳男子 2021-01-20 02:39

I am going to write a program that performs Windows OS version check, since I can do it with sys.windowsversion()[0] or with platform module that returns string not int what

2条回答
  •  滥情空心
    2021-01-20 02:49

    You can do it by calling sys.getwindowsversion. For example this output:

    >>> sys.getwindowsversion()
    sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
    

    is for Windows 7.

    Source: http://mail.python.org/pipermail/tutor/2003-November/026227.html

提交回复
热议问题