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 经测试,此方法无效,呵呵……
相关问答:
像 C 的 scanf() 那样 比如读入 1 2 3 a b c 每次读入一个 下面这个应该是你想要的吧: Python code: >>> k = raw_input() 0 0123 ds dsl sd >>> k '0 0123 ds dsl sd' >>> ......
在list中添加一个类的局部变量 这样做是否合法 请看下面例子: Python code: class A(): def __init__( self ): self.__a = 0 self.__b = 'hello' def get_a( self ): ret ......
>>> x=-1 >>> if x>0: print ('11') >>> else: SyntaxError: invalid syntax (<pyshell#20>, line 1) 网上搜的也是: >>> x=int(input("Please ent ......
我在批处理中调用python脚本 如下: call %pyscript%\StaticResult.py -s D:\DailySDV\Bts8.1\TestLog\TestResult.xml -d %CiRoot_WndPath%\cruisecontrol\userData\groups\group01\projects\%ProjectName%\%GtrRl ......
RowNum=18 ColumnNum=10 SquareList=[[0 for a in range(ColumnNum)] for b in range(RowNum)] ActiveList=[[0 for a in range(ColumnNum)] for b in range(RowNum)] ActiveList[0][5]=1 SquareL ......