做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

python實現自動更換ip的方法

來源:懂視網 責編:小采 時間:2020-11-27 14:41:35
文檔

python實現自動更換ip的方法

python實現自動更換ip的方法:本文實例講述了python實現自動更換ip的方法。分享給大家供大家參考。具體實現方法如下: #!/usr/bin/env python #-*- encoding:gb2312 -*- # Filename: IP.py import sitecustomize import _winreg import Confi
推薦度:
導讀python實現自動更換ip的方法:本文實例講述了python實現自動更換ip的方法。分享給大家供大家參考。具體實現方法如下: #!/usr/bin/env python #-*- encoding:gb2312 -*- # Filename: IP.py import sitecustomize import _winreg import Confi

本文實例講述了python實現自動更換ip的方法。分享給大家供大家參考。具體實現方法如下:

#!/usr/bin/env python
#-*- encoding:gb2312 -*-
# Filename: IP.py
import sitecustomize
import _winreg
import ConfigParser
from ctypes import *
print '正在進行網絡適配器檢測,請稍候…'
print
netCfgInstanceID = None
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 
r'SystemCurrentControlSetControlClass{4d36e972-e325-11ce-bfc1-08002be10318}')
keyInfo = _winreg.QueryInfoKey(hkey)
# 尋找網卡對應的適配器名稱 netCfgInstanceID
for index in range(keyInfo[0]):
hSubKeyName = _winreg.EnumKey(hkey, index)
hSubKey = _winreg.OpenKey(hkey, hSubKeyName)
try:
hNdiInfKey = _winreg.OpenKey(hSubKey, r'NdiInterfaces')
lowerRange = _winreg.QueryValueEx(hNdiInfKey, 'LowerRange')
# 檢查是否是以太網
if lowerRange[0] == 'ethernet':
driverDesc = _winreg.QueryValueEx(hSubKey, 'DriverDesc')[0]
print '檢測到網絡適配器名:', driverDesc
netCfgInstanceID = _winreg.QueryValueEx(hSubKey, 'NetCfgInstanceID')[0]
print '檢測到網絡適配器ID:', netCfgInstanceID
if netCfgInstanceID == None:
print '沒有找到網絡適配器,程序退出'
exit()
break
_winreg.CloseKey(hNdiInfKey)
except WindowsError:
print r'Message: No NdiInterfaces Key'
# 循環結束,目前只提供修改一個網卡IP的功能
_winreg.CloseKey(hSubKey)
_winreg.CloseKey(hkey)
# 通過修改注冊表設置IP
strKeyName = 'System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\' + netCfgInstanceID
print '網絡適配器的注冊表地址是:
', strKeyName
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 
strKeyName, 
0, 
_winreg.KEY_WRITE)
config = ConfigParser.ConfigParser()
print
print '正在打開IP.ini配置文件…'
config.readfp(open('IP.ini'))
IPAddress = config.get("school","IPAddress")
SubnetMask = config.get("school","SubnetMask")
GateWay = config.get("school","GateWay")
DNSServer1 = config.get("school","DNSServer1")
DNSServer2 = config.get("school","DNSServer2")
DNSServer = [DNSServer1,DNSServer2]
print '配置文件內設定的信息如下,請核對:'
print
print 'IP地址:', IPAddress
print '子關掩碼:', SubnetMask
print '默認網關:', GateWay
print '主DNS服務器:', DNSServer1
print '次DNS服務器:', DNSServer2
print
res = raw_input('現在,請您決定:輸入1,則將配置文件寫入系統;輸入2,則將現有的系統設定還原為全部自動獲取;否則程序退出:')
if str(res) == '1':
try:
_winreg.SetValueEx(hkey, 'EnableDHCP', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'IPAddress', None, _winreg.REG_MULTI_SZ, [IPAddress])
_winreg.SetValueEx(hkey, 'SubnetMask', None, _winreg.REG_MULTI_SZ, [SubnetMask])
_winreg.SetValueEx(hkey, 'DefaultGateway', None, _winreg.REG_MULTI_SZ, [GateWay])
_winreg.SetValueEx(hkey, 'NameServer', None, _winreg.REG_SZ, ','.join(DNSServer))
except WindowsError:
print 'Set IP Error'
exit()
_winreg.CloseKey(hkey)
print '切換成功!重置網絡后即可生效'
elif str(res) == '2':
try:
_winreg.SetValueEx(hkey, 'EnableDHCP', None, _winreg.REG_DWORD, 0x00000001)
_winreg.SetValueEx(hkey, 'T1', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'T2', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'NameServer', None, _winreg.REG_SZ, None)
_winreg.SetValueEx(hkey, 'DhcpConnForceBroadcastFlag', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'Lease', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'LeaseObtainedTime', None, _winreg.REG_DWORD, 0x00000000)
_winreg.SetValueEx(hkey, 'LeaseTerminatesTime', None, _winreg.REG_DWORD, 0x00000000)
except WindowsError:
print 'Set IP Error'
exit()
_winreg.CloseKey(hkey)
print '切換成功!重置網絡后即可生效'
else:
print '用戶手動取消,程序退出'
exit('')

希望本文所述對大家的Python程序設計有所幫助。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

python實現自動更換ip的方法

python實現自動更換ip的方法:本文實例講述了python實現自動更換ip的方法。分享給大家供大家參考。具體實現方法如下: #!/usr/bin/env python #-*- encoding:gb2312 -*- # Filename: IP.py import sitecustomize import _winreg import Confi
推薦度:
標簽: 設置 更改 ip
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 吴堡县| 格尔木市| 玛纳斯县| 福泉市| 仙居县| 谢通门县| 电白县| 长顺县| 芦山县| 新民市| 汉中市| 平顶山市| 阿瓦提县| 新民市| 延寿县| 阆中市| 白银市| 密云县| 保亭| 杂多县| 嘉义市| 都兰县| 上蔡县| 洛阳市| 宣城市| 汤原县| 财经| 乌鲁木齐县| 日土县| 思茅市| 永顺县| 崇明县| 财经| 祁阳县| 苏尼特左旗| 乾安县| 略阳县| 淳安县| 濮阳市| 滦平县| 仪陇县|