Python 操作注册表
通过Python的内置模块winreg这里主要给出一些winreg的Demo代码
Python2:import _winreg、Python3:import winreg
#!python37
# -*- coding: utf-8 -*-
# coding:utf-8
import winreg
def obtain():
# 获取该键的所有键值
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\\Inspiry\\BasePay\\Address")
# 获取该键的所有键值,遍历枚举
try:
i = 0
while 1:
# EnumKey用来枚举子键,EnumValue方法用来枚举键值,
name, value, type1 = winreg.EnumValue(key, i)
# print(repr(name),value)
return value
i +=1
except WindowsError:
print('error')
if __name__ == '__main__':
obtain()