#!/usr/bin/env python #coding:utf-8 import _winreg key = "想要获取的键" open_key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key) countkey=_winreg.QueryInfoKey(open_key)[0] keylist=[] for i in range(int(countkey)): name=_winreg.EnumKey(open_key,i) #获取子键名 keylist.append(name) _winreg.CloseKey(open_key) print keylist