| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
# 
# script to register Python 2.0 or later for use with win32all 
# and other extensions that require Python registry settings 
# 
# written by Joakim Löw for Secret Labs AB / PythonWare 
# 
# source: 
# http://www.pythonware.com/products/works/articles/regpy20.htm 
 
import sys 
 
from _winreg import * 
 
# tweak as necessary 
version = sys.version[:3] 
installpath = sys.prefix 
 
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version) 
installkey = "InstallPath" 
pythonkey = "PythonPath" 
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( 
    installpath, installpath, installpath 
) 
 
def RegisterPy(): 
    try: 
        reg = OpenKey(HKEY_LOCAL_MACHINE, regpath) 
    except EnvironmentError: 
        try: 
            reg = CreateKey(HKEY_LOCAL_MACHINE, regpath) 
            SetValue(reg, installkey, REG_SZ, installpath) 
            SetValue(reg, pythonkey, REG_SZ, pythonpath) 
            CloseKey(reg) 
        except: 
            print "*** Unable to register!"  # 为什么程序运行到这段代码就提示错误了呢?(提示:Missing parentheses in call to 'print'.Did you mean print("*** Unable to register!")?) 
            return 
        print "--- Python", version, "is now registered!" 
        return 
    if (QueryValue(reg, installkey) == installpath and 
        QueryValue(reg, pythonkey) == pythonpath): 
        CloseKey(reg) 
        print "=== Python", version, "is already registered!" 
        return 
    CloseKey(reg) 
    print "*** Unable to register!" 
    print "*** You probably have another Python installation!" 
 
if __name__ == "__main__": 
    RegisterPy() |   
 
 
 
 |