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

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


"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1046623684.25117.python-list at python.org...
> [Chen]
> > Is it possible to detect whether the OS is win9x or winnt?
> >
> > I used os.name but it returns "winnt" even on win98se. While
sys.platform
> > 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
shell
> that supports the VER command.
>
>

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

Chen







More information about the Python-list mailing list