python 3 安裝mysql包時遇到的 python 3.x no found


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! %s " % (pythonpath))
            return
        print ("--- Python"+ version+"is now registered!")
        return
    print ("--- Python"+ version+"is now registered!")
RegisterPy()

保存爲*.py 然後用管理員權限執行,跟python2.x相比有點區別,兩個方面 

1 導入包爲  winreg  python 2.x 爲  _winreg

2 print 的差別

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章