#!/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()