因为,要测试一些东西。需要频繁改HOSTS。一直就想弄个脚本来实现~~~~,今天努力了。
但是未遂:-(
这招行不通。说权限不够
dest_dir="C:\\WINDOWS\\system32\\drivers\\etc\\hosts"
f=open("dest_dir","a+")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
file_path = "C:\\WINDOWS\\system32\\drivers\\etc\\hostsnew"
os.remove(dest_dir)
aa='C:\\WINDOWS\\system32\\drivers\\etc\\hosts'
os.copy(file_path,dest_dir)
这招也行不通,直接不给提示,只说错误
PS:系统xp
但是未遂:-(
这招行不通。说权限不够
dest_dir="C:\\WINDOWS\\system32\\drivers\\etc\\hosts"
f=open("dest_dir","a+")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
file_path = "C:\\WINDOWS\\system32\\drivers\\etc\\hostsnew"
os.remove(dest_dir)
aa='C:\\WINDOWS\\system32\\drivers\\etc\\hosts'
os.copy(file_path,dest_dir)
这招也行不通,直接不给提示,只说错误
PS:系统xp