from tkinter import *
import hashlib
root = Tk()
text = Text(root, width=30, height=5)
text.pack()
text.insert(INSERT, 'www.baidu.com')
contents = text.get('1.0', END)
def getSig(contents):
m = hashlib.md5(contents.encode())
return m.digest() #digest:摘要
sig = getSig(contents)
def check():
#重新获取当前的文本
contents = text.get('1.0', END)
#与之前的相比较
if sig != getSig(contents):
print("warning")
else:
print("that's ok")
Button(root, text='check', command=check).pack()
mainloop()
python tkinter 检查与之前内容是否有不同
最新推荐文章于 2021-10-06 17:20:48 发布