Python os.name return nt on windows 7

Python os.name return nt on windows 7

You can use platform module to check:

In [244]: import platform

In [247]: platform.version()
Out[247]: 6.1.7601

In [248]: platform.system()
Out[248]: Windows

In [249]: platform.release()
Out[249]: 7

In [250]: platform.win32_ver()
Out[250]: (7, 6.1.7601, SP1, Multiprocessor Free)

In [268]: platform.platform()
Out[268]: Windows-7-6.1.7601-SP1

So just use platform.system() == Windows and platform.release() == 7 to check 😉

Or simplier Windows-7 in platform.platform().

The os-module lets us run different code dependent on which operating system the code is running on.

nt means that you are running windows, and
posix mac

If you want to check if OS is Windows or Linux or OSX then the most reliable way is platform.system().
If you want to make OS-specific calls but via built-in Python modules posix or nt then use os.name.

>>> import platform
>>> platform.system()

Windows # for Linux it prints Linux, Mac it prints `Darwin

Refer here for more. Python: What OS am I running on?

Python os.name return nt on windows 7

nt means New Technology which is come with the release of a 32-bit version initially. But after that, the name carried over simply without any specific meaning.
for further information please refer: what is NT?

Leave a Reply

Your email address will not be published.