开发者

python3 string encoding

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜