1. 程式人生 > >修改hosts文件的腳本1.0

修改hosts文件的腳本1.0

linu spa dns span main 腳本 system form pan

import sys


IP_input = input("Please input IP:")
DNS_input = input("Please input Domain-Name:")
if sys.platform == ‘win32‘:
with open(r‘C:\Windows\System32\drivers\etc\host‘, ‘a‘) as f:
f.write(IP_input + ‘ ‘+DNS_input)
elif sys.platform == ‘linux‘ or sys.platform == ‘darwin‘:
with open(‘/etc/hosts‘, ‘a‘) as f:
f.write(IP_input + ‘ ‘ + DNS_input)
else:
pass

修改hosts文件的腳本1.0