鱼C论坛

 找回密码
 立即注册
查看: 1403|回复: 3

tkinter

[复制链接]
发表于 2017-10-23 11:50:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from tkinter import *
import hashlib

root = Tk()

text = Text(root, width=30, height=5)
text.pack()

text.insert(INSERT, "I love Fishc.com!")
contents = text.get("1.0", END)

def getSig(contents):
    m = hashlib.md5(contents.encode())
    return m.digest()

sig = getSig(contents)

def check():
    ontents = text.get("1.0", END)
    if sig == getSig(contents):
        print("警报:内容发生变动!")
    else:
        print("风平浪静")

Button(root, text="检查", command=check).pack()

mainloop()
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2017-10-23 11:51:38 | 显示全部楼层
不管删除或增加都是输出警报, 风平浪静打不出来,这是为啥
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-10-23 12:48:23 | 显示全部楼层
2017-10-23_124724.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-10-23 14:30:08 | 显示全部楼层
from tkinter import *
import hashlib

root = Tk()

text = Text(root, width=30, height=5)
text.pack()

text.insert(INSERT, "I love Fishc.com!")
contents = text.get(1.0, END)

def getSig(contents):
    m = hashlib.md5(contents.encode())
    return m.digest()

sig = getSig(contents)

def check():
    ontents = text.get(1.0, END)
    if sig != getSig(contents):
        print("警报:内容发生变动!")
    else:
        print("风平浪静")

Button(root, text="检查", command=check).pack()

mainloop()



这样还是不行啊不管什么结果都是风平浪静!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-12-25 11:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表