鱼C论坛

 找回密码
 立即注册
查看: 2294|回复: 1

显示AttributeError: 'NoneType' object has no attribute 'get' 怎么解决呢?

[复制链接]
发表于 2021-3-10 21:34:36 | 显示全部楼层 |阅读模式

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

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

x
  1. from tkinter import *

  2. root=Tk()

  3. label1=Label(root,text='凯撒密码').grid(row=0,column=1)

  4. label2=Label(root,text='明文:').grid(row=2,column=1)

  5. txt1=Text(root,width=20,height=2).grid(row=2,column=2)

  6. label3=Label(root,text='密文:').grid(row=3,column=1)

  7. txt2=Text(root,width=20,height=2).grid(row=3,column=2)

  8. label4=Label(root,text='密钥:').grid(row=4,column=1)

  9. txt3=Text(root,width=20,height=2).grid(row=4,column=2)

  10. def decode():
  11.             s=txt2.get("1.0",end)  
  12.             p=Int(txt3.get("1.0",end))
  13.             for q in s:
  14.                 if 'a'<=q<='z':
  15.                     #print(chr(ord(q)-p),end='')
  16.                     txt1.insert(chr(ord(q)-p))
  17.                 elif 'A'<=q<='z':
  18.                     #print(chr(ord(q)-p),end='')
  19.                     txt1.insert(chr(ord(q)-p))
  20.                 else:
  21.                      #print(q,end='')
  22.                     txt1.insert(q)

复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-3-10 21:48:32 From FishC Mobile | 显示全部楼层
不要这样写
  1. label2=Label(root,text='明文:').grid(row=2,column=1)
复制代码
因为grid方法返回值为None,这样label2的值就是None而不是Label的实例。把他们拆分开:
  1. label2=Label(root,text='明文:')
  2. label2.grid(row=2,column=1)
复制代码
其他地方同理。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-26 21:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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