1. python注册表信息在哪个文件夹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import winreg

def show_software():
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'software', 0, winreg.KEY_READ)
result = []
index = 0
while True:
try:
name = winreg.EnumKey(key, index)
result.append(name)
index += 1
except OSError:
break
winreg.CloseKey(key)
print(result)

if __name__ == '__main__':
show_software()

2. Python怎么取到本机所有安装的软件

不同的系统api不一样,windows上可以调用wmi接口

3. python的_winreg的SetValueEx如何使用

去google搜SetValueEx
可以抄找到python的官网解释,其对于
_winreg.SetValueEx(key, value_name, reserved, type, value)
中的value是:
value is a string that specifies the new value.
而你所说的:
REG_MULTI_SZ

_winreg.REG_MULTI_SZ

的确官网解释是你所说的。
但是,另外再去google搜:

REG_MULTI_SZ
可以找到微软官网的解释,给的例子是:

String1\0String2\0String3\0LastString\0\0
所以,看起来,估计你是搞错你的类型。
估计改为:
REG_SZ
就可以了。

最重要的:
你要自己清楚为何你自己去设置类型为REG_MULTI_SZ
或者你说出你的本意,别人或许会帮你找到,更合适的办法和设置的值的类型。

4. python如何获取串口前面的名称

楼上的方法太复杂,用serial库就可以,亲测可用:

importserial.tools.list_ports
port_list=list(serial.tools.list_ports.comports())
iflen(port_list)==0:
print('找不到串口')
else:
foriinrange(0,len(port_list)):
print(port_list[i])

参考:网页链接

5. python里面的注册表怎么进去

在Python的标准库中,_winreg.pyd可以操作Windows的注册表,另外第三方的win32库封装了大量的Windows API,使用起来也很方便。不过这里介绍的是使用_winreg操作注册表,毕竟是Python自带的标准库,无需安装第三方库。

下面的例子是通过Python获取Windows
XP下已经安装的补丁号。Windows的补丁号都在“HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft
\\Updates”下,通过循环下面所有的目录节点,如果找到的名称符合正则表达式KB(\d{6}).*,则表示是一个补丁号。

从例子可以看出操作起来非常的简单和快速。

复制代码 代码如下:

# -*- coding: utf-8 -*-
# 获取Windows的已打的补丁号
from _winreg import *
import re

def subRegKey(key, pattern, patchlist):
# 个数
count = QueryInfoKey(key)[0]
for index in range(count):
# 获取标题
name = EnumKey(key, index)
result = patch.match(name)
if result:
patchlist.append(result.group(1))
sub = OpenKey(key, name)
subRegKey(sub, pattern, patchlist)
CloseKey(sub)

if __name__ == '__main__':
patchlist = []
updates = 'SOFTWARE\\Microsoft\\Updates'
patch = re.compile('(KB\d{6}).*')
key = OpenKey(HKEY_LOCAL_MACHINE, updates)
subRegKey(key, patch, patchlist)
print 'Count: ' + str(len(patchlist))
for p in patchlist:
print p
CloseKey(key)

下面内容转自 Python Standard Library12.13 The _winreg Mole
(Windows
only, New in 2.0) The _winreg mole provides a basic interface to the
Windows registry database. Example 12-17 demonstrates the mole.
Example 12-17. Using the _winreg Mole
File: winreg-example-1.py

复制代码 代码如下:

import _winreg
explorer = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\CurrentVersion\\Explorer"
)

#list values owned by this registry key
try:
i = 0
while 1:
name, value, type= _winreg.EnumValue(explorer, i)
print repr(name),
i += 1
except WindowsError:
print

value, type = _winreg.QueryValueEx(explorer, "Logon User Name")

print
print "user is", repr(value)

'Logon User Name' 'CleanShutdown' 'ShellState' 'Shutdown Setting'
'Reason Setting' 'FaultCount' 'FaultTime' 'IconUnderline'...
user is u'Effbot'

6. python 创建注册表

http://blog.sina.com.cn/s/blog_4b5039210100gmsb.html
winreg.SetValue(key, "MyNewKey", winreg.REG_SZ, "New")这句话应该改成
winreg.SetValue(newkey, "MyNewKey", winreg.REG_SZ, "New")给新建的键改值

7. python修改注册表拒绝访问

用管理员运行python.exe,才能修改吧

8. Python代码来读取注册表问题,怎么解决

windows上的python有内置模块winreg用于操作注册表,其文档可以在 开始>所有程序>Python>Python Mole Docs中找到

9. Python 问题

这个就是说明你的python没有_winreg这个模块,现在python换成了winreg这个模块