1 #检查文本
2 from tkinter import *
3 import hashlib
4
5 master=Tk()
6 text = Text(master,width=30,height=5)
7 text.pack()
8 text.insert(INSERT,'I love coding!')
9 content = text.get('1.0',END)
10 #获取MD5验证
11 def getmd5(content):
12 m = hashlib.md5(content.encode())
13 return m.digest()
14 #获取之前的MD5认证
15 before = getmd5(content)
16 #检查的函数
17 def check():
18 content=text.get('1.0',END)
19 if getmd5(content) != before:
20 print('注意了哈,有变动!')
21 else:
22 print('你知道的,没什么变化~摊手~')
23
24
25 b = Button(master,text='检查',command=check)
26 b.pack()
27
28 mainloop()