all Python 3Windowsplatformfunction
platform.win32_ver()
specific operating systems
The Windows version as a (release, version, csd, ptype) tuple, e.g. ('11', '10.0.22631', 'SP0', 'Multiprocessor Free'); empty strings on other OSes.
Syntax
release, version, csd, ptype = platform.win32_ver(release='', version='', csd='', ptype='')
You can call it anywhere: on Linux and macOS it does not fail but returns the defaults, four empty strings, so 'if platform.win32_ver()' is true everywhere, because a non-empty tuple is truthy. Check the first item or sys.platform == 'win32' instead.
Examples
import platform
ver = platform.win32_ver()
print(len(ver), bool(ver)) # → 4 True — кортеж истинен даже из пустых строк
print(ver) # → ? на Windows ('11', '10.0.22631', 'SP0', 'Multiprocessor Free'), иначе ('', '', '', '')
See also
Open in the full glossarydocs.python.orgReport an inaccuracy