ctypesの場合には(?起因する32 64対ビットに)動作しませんを参照、このハックはすべき:
def get_Windows_name():
import subprocess, re
o = subprocess.Popen('systeminfo', stdout=subprocess.PIPE).communicate()[0]
try: o = str(o, "latin-1") # Python 3+
except: pass
return re.search("OS Name:\s*(.*)", o).group(1).strip()
print(get_Windows_name())
それとも、レジストリを読み取る:
try: import winreg
except: import _winreg as winreg
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion") as key:
print(winreg.QueryValueEx(key, "EditionID")[0])
または使用この:
from win32com.client import GetObject
wim = GetObject('winmgmts:')
print([o.Caption for o in wim.ExecQuery("Select * from Win32_OperatingSystem")][0])
http://stackoverflow.com/questions/2816821/identify-windows-editions-with-python –
Iトンを参照してください。純粋なPythonを使用している場合は、この "https://bitbucket.org/gastlygem/wistron/src/c16e2cfe1445/wistron.preload/wistron/preload/ostype.py"を解決する必要があります。 私はPython APIを完全にサポートしていない可能性があるSquish QTでPythonを使用しているので、ctypesのインポートに失敗しました。だから、可能であればレジストリから版を取り出すことを考えているのですか? – Cthoong