How do I check if I’m running on Windows in Python? [duplicate]

Python os module

Specifically for Python 3.6/3.7:

os.name: The name of the operating
system dependent module imported. The
following names have currently been
registered: ‘posix’, ‘nt’, ‘java’.

In your case, you want to check for ‘nt’ as os.name output:

import os

if os.name == 'nt':
     ...

There is also a note on os.name:

See also sys.platform has a finer granularity. os.uname() gives
system-dependent version information.

The platform module provides
detailed checks for the system’s identity.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)