Is the OS win9x or winnt? How to detect it?

Chen chenpuqing at
Mon Mar 3 01:45:38 CET 2003

"Tim Peters" < at> wrote in message
news:mailman.1046623684.25117.python-list at
> [Chen]
> > Is it possible to detect whether the OS is win9x or winnt?
> >
> > I used but it returns "winnt" even on win98se. While
> > returns "win32".
> sys.getwindowsversion() is new in Python 2.3, and returns a 5-tuple of
> values built from from calling the Win32 GetVersionEx() function.
> Before 2.3, you have to do something trickier.  For example,
>     version_string = os.popen("ver").read()
> and then parse version_string, assuming the box's COMPSPEC points to a
> that supports the VER command.

It works very well! Many thanks to all of you!


More information about the Python-list mailing list