|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- root=Tk()
- label1=Label(root,text='凯撒密码').grid(row=0,column=1)
- label2=Label(root,text='明文:').grid(row=2,column=1)
- txt1=Text(root,width=20,height=2).grid(row=2,column=2)
- label3=Label(root,text='密文:').grid(row=3,column=1)
- txt2=Text(root,width=20,height=2).grid(row=3,column=2)
- label4=Label(root,text='密钥:').grid(row=4,column=1)
- txt3=Text(root,width=20,height=2).grid(row=4,column=2)
- def decode():
- s=txt2.get("1.0",end)
- p=Int(txt3.get("1.0",end))
- for q in s:
- if 'a'<=q<='z':
- #print(chr(ord(q)-p),end='')
- txt1.insert(chr(ord(q)-p))
- elif 'A'<=q<='z':
- #print(chr(ord(q)-p),end='')
- txt1.insert(chr(ord(q)-p))
- else:
- #print(q,end='')
- txt1.insert(q)
复制代码 |
|