介绍
这篇文章将为大家详细讲解有关如何将python安装信息加入注册表,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
<强> py3.5.2 强>
import 系统 得到winreg import * #,tweak as 必要的 时间=version sys.version [3] installpath =sys.prefix 时间=regpath “Python软件\ \ \ \ Pythoncore \ \ % s \ \“, %,(版本) 时间=installkey “InstallPath" 时间=pythonkey “PythonPath" 时间=pythonpath “% s % s \ \ Lib \ \; % s \ \ dll \ \“, %, ( ,,installpath, installpath, installpath ) def RegisterPy (): 尝试才能: ,,,reg =, OpenKey (HKEY_CURRENT_USER, regpath) except 才能;EnvironmentError  as e: ,,,试一试: ,,,,,reg =, CreateKey (HKEY_CURRENT_USER, regpath) ,,,,,SetValue (reg, installkey,, REG_SZ,, installpath) ,,,,,SetValue (reg, pythonkey,, REG_SZ,, pythonpath环境) ,,,,,CloseKey(注册) ,,,除了: ,,,,,印刷(“* * *,Unable 用寄存器!“) ,,,,,回来 ,,,print(“——安康;Python",,版本,,“is 你注册!“) ,才能返回 if 才能;(QueryValue (reg, installkey),==, installpath 和 ,,,QueryValue (reg, pythonkey),==, pythonpath环境): ,,,CloseKey(注册) ,,,print (“===, Python",,版本,,“is already 注册!“) ,才能返回 CloseKey才能(注册) 打印才能(“* * *,Unable 用寄存器!“) 打印才能(“* * *,你probably have another Python 安装!“) if __name__ ==,“__main__": RegisterPy才能()
<强> py2。*版本强>
& # 39; & # 39; & # 39; 解决注册问题,pywin32安装存在问题 & # 39;& # 39;& # 39; import 系统 得到_winreg import * #,tweak as 必要的 时间=version sys.version [3] installpath =sys.prefix 时间=regpath “Python软件\ \ \ \ Pythoncore \ \ % s \ \“, %,(版本) 时间=installkey “InstallPath" 时间=pythonkey “PythonPath" 时间=pythonpath “% s % s \ \ Lib \ \; % s \ \ dll \ \“, %, ( ,,installpath, installpath, installpath ) def RegisterPy (): 尝试才能: ,,,reg =, OpenKey (HKEY_CURRENT_USER, regpath) except 才能;EnvironmentError  as e: ,,,试一试: ,,,,,reg =, CreateKey (HKEY_CURRENT_USER, regpath) ,,,,,SetValue (reg, installkey,, REG_SZ,, installpath) ,,,,,SetValue (reg, pythonkey,, REG_SZ,, pythonpath环境) ,,,,,CloseKey(注册) ,,,除了: ,,,,,print “* * *, Unable 用寄存器!“ ,,,,,回来 ,,,print “——安康;Python",,,,“is 你注册!“ ,才能返回 if 才能;(QueryValue (reg, installkey),==, installpath 和 ,,,QueryValue (reg, pythonkey),==, pythonpath环境): ,,,CloseKey(注册) ,,,print “===, Python",,版本,,“is already 注册!“ ,才能返回 CloseKey才能(注册) print 才能“* * *,Unable 用寄存器!“ print 才能“* * *,你probably have another Python 安装!“ if __name__ ==,“__main__": RegisterPy才能()
关于如何将python安装信息加入注册表就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。