python中字符串比较的有关问题的有关问题

python中字符串比较的问题的问题
以下代码是Tk做了一个简单的密码验证功能,输入一个字符串,并验证其是否正确,请先看代码:
Python code

from tkinter import *

root = Tk()
e = StringVar()
t = 'cashlu'

def yanzheng():
    if e == t:
        e.set('Good!')
    else:
        e.set('Wrong!')

entry = Entry(root,
              textvariable = e)
button = Button(root,
                text = 'OK',
                command = yanzheng)
entry.pack()
button.pack()
root.mainloop()



问题:
  为什么即使我在对话框中输入正确的密码‘cashlu’,它依旧提示Wrong?

------解决方案--------------------
试试 str(e) == t
------解决方案--------------------
StringVar是个类直接和字串比较都是false,试试改e.get() == t 或者 entry.get() == t
看看代码里,你接着也是用e.set('Good!')而不是e='Good!'