开发者

python3 string encoding

开发者 https://www.devze.com 2023-03-01 08:54 出处:网络
What I\'m trying to do is to ask for password when user tries to close application. I stored the password in a text file for now. But even if I enter the correct password application won\'t close and

What I'm trying to do is to ask for password when user tries to close application. I stored the password in a text file for now. But even if I enter the correct password application won't close and is saying that I have entered wrong password(prints IGNORE1). I tried different encodings of file with password but nothing worked. Encoding of file is UTF-8

  def closeEvent(self, event):
    heslo_zadane = self.showDialog()
    in_file = open("klient.cfg", "rt")
    main_heslo = in_file.read()
    in_file.close()
    if heslo_zadane[1] == True:
      if heslo_zadane[0] == main_heslo:
        event.accept()
      else:
        event.ignore()
    else:
      event.ignore()

  def showDialog(self):
    text, ok = QtGui.QInputDialog.getText(se开发者_运维知识库lf, 'Vypnutie Klienta', 
        'Zadajte správcovské heslo:')
    return text, ok


Is there maybe a line ending on the password in the file? Otherwise it should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消