0

如何在 windows8 中使用 python 设置代理设置?我试过这段代码但没有工作..设置没有改变

def inst_proxy5(self):
    """ sets institute proxy"""
    INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
    r'Software\Microsoft\Windows\CurrentVersion\Internet Settings',
    0, winreg.KEY_ALL_ACCESS)
    def set_key(name, value):
        _, reg_type = winreg.QueryValueEx(INTERNET_SETTINGS, name)
        winreg.SetValueEx(INTERNET_SETTINGS, name, 0, reg_type, value)
    set_key('ProxyEnable', 1)
    set_key('ProxyOverride', u'*.local;<local>')  # Bypass the proxy for localhost
    set_key('ProxyServer', u'192.168.0.5:3128')
    root.destroy()`

如果我评论它的工作..如何设置它

set_key('ProxyOverride', u'*.local;<local>')  # Bypass the proxy for localhost

它给出了这个错误:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "C:\py_pro\but1.py", line 82, in inst_proxy22
    set_key('ProxyOverride', u'*.local;<local>')  # Bypass the proxy for localhost
  File "C:\py_pro\but1.py", line 79, in set_key
    _, reg_type = winreg.QueryValueEx(INTERNET_SETTINGS, name)
WindowsError: [Error 2] The system cannot find the file specified
4

0 回答 0