本人win7系统 python3.6 32位 想通过ip代理来改变ip地址 不知道python有什么命令可以直接改 跪谢!!!
3条回答 默认 最新
- threenewbee 2018-02-22 16:02关注
你这个不是修改ip,而是修改代理ip的设置,这个设置在注册表里,可以修改,下面的代码仅供参考:
import socket import os import winreg def get_local_address(): return socket.gethostbyname(socket.gethostname()) # get the ip address of this computer ip = get_local_address() #get the first 3 digits of ip ipStart = ip[:3] print(ip) key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,r"Software\Microsoft\Windows\CurrentVersion\Internet Settings",0,winreg.KEY_ALL_ACCESS) #in company if ipStart == "XXX": print("proxy") winreg.SetValueEx(key,"ProxyEnable",0, winreg.REG_DWORD, 1) winreg.SetValueEx(key,"ProxyServer",0, winreg.REG_SZ, "proxy:port") winreg.SetValueEx(key,"ProxyOverride",0, winreg.REG_SZ, "*.company.com;<local>") #home else: print("disable proxy") winreg.SetValueEx(key,"ProxyEnable",0, winreg.REG_DWORD, 0)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 孟德尔随机化结果不一致
- ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀
- ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
- ¥15 关于#hadoop#的问题
- ¥15 (标签-Python|关键词-socket)
- ¥15 keil里为什么main.c定义的函数在it.c调用不了
- ¥50 切换TabTip键盘的输入法