欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

python hosts 我自己亲自做成的 py 文件 ,可以生成 exe 我己经生成了 exe , 放在了 192.168.0.1 上 有大用 有大大用

replace_hosts.py


#!/usr/bin/python3
#
import tkinter as tk
text = """127.0.0.1 localhost
255.255.255.255 broadcasthost
::1             localhost
17.113.148.229 222.qwert.com
17.113.148.230 333.qwert.com
17.113.148.228 444.corp.qwert.com
17.35.69.1 555.corp.qwert.com
127.0.0.1 666.qwert.com
17.113.148.229 7777.qwert.com
17.113.148.230 888.qwert.com
17.113.148.228 9999.corp.qwert.com
17.129.252.28 qqq.qwert.com
17.129.252.28 qqqq.ecs.qwert.com
127.0.0.1 eee.qwert.com
17.239.123.132    ttt.corp.qwert.com  idmsauth.igb.qwert.com  idmsauth-nwk.corp.qwert.com
17.239.123.133    tttt.qwert.com
17.239.123.134     uuuuu.qwert.com
17.239.123.135  iiiii.corp.qwert.com
17.239.123.134 ooooo.qwert.com mfg9
17.35.69.1        pppppp.corp.qwert.com
10.54.2.2    bbbb.com.cn
10.54.2.3    bbbb.com.cn
"""
with open("C:\\Windows\\System32\\drivers\\etc\\hosts", "w") as file:
    file.write(text)

def okqqq():
    root.destroy()

root = tk.Tk()
root.title('更新hosts')
label = tk.Label(root, text="    ")
label.pack()

label1 = tk.Label(root, text="成功更新hosts!")
label1.pack()

btn = tk.Button(root,command=root.destroy)
btn["text"] = "确定"
btn.pack()
root.geometry("300x90") #不能设宽度,才能居中
root.mainloop()



普通分类: