quentix727 2022-09-12 07:52 采纳率: 0%
浏览 17

关于两个字符串内容一样python却说不一样的事

“关于两个字符串内容一样python却说不一样的事”

截图:

img

代码:

# -*- coding:utf-8 -*-
import sys
import wx


class MyFrame(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, title='Login', size=(400, 300))
        panel = wx.Panel(self)

        self.title = wx.StaticText(panel, label='Input username and password', pos=(120, 20))
        self.label_user = wx.StaticText(panel, label='Username', pos=(40, 50))
        self.text_user = wx.TextCtrl(panel, size=(235, 25), pos=(100, 50), style=wx.TE_LEFT)
        self.label_pwd = wx.StaticText(panel, label='Password', pos=(40, 90))
        self.text_password = wx.TextCtrl(panel, size=(235, 25), pos=(100, 90), style=wx.TE_PASSWORD)

        self.bt_confirm = wx.Button(panel, label='Confirm', pos=(150, 130))
        self.bt_confirm.Bind(wx.EVT_BUTTON, self.OnclickSubmit)
        self.bt_cancel = wx.Button(panel, label='Cancel', pos=(255, 130))
        self.bt_cancel.Bind(wx.EVT_BUTTON, self.OnclickCancel)
        self.bt_registered = wx.Button(panel, label='Register', pos=(45, 130))
        self.bt_registered.Bind(wx.EVT_BUTTON, self.OnclickRegister)

    def OnclickRegister(self, ever):
        pass

    def OnclickSubmit(self, even):
        file = open('res/information.txt', 'r')
        users = file.readlines()
        for i in users:
            username = self.text_user.GetValue()
            password = self.text_password.GetValue()
            style = username + ';' + password
            print(i + '\n' + str(type(i)))
            print(style + '\n' + str(type(style)))
            if username == '' or password == '':
                wx.MessageBox('Username and password cannot be null.')
            elif users == style:
                wx.MessageBox('Login succeeded.')
            else:
                wx.MessageBox('Username and password do not match')
            break
        file.close()

    def OnclickCancel(self, event):
        sys.exit(0)


if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(parent=None, id=-1)
    frame.Show()
    app.MainLoop()


在当前目录下的res文件夹里还有一个information.txt,其内容为:
root;root

气人!

  • 写回答

1条回答 默认 最新

  • honestman_ 2022-09-12 08:34
    关注

    这里说的是用户密码不匹配,指的是用户密码写错了,不是说用户密码完全一样

    评论

报告相同问题?

问题事件

  • 创建了问题 9月12日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表