-1

I am programming an app with python 3.8.3 and pyQt5. Here's a part of my code:

def logind(self):
        datas=open('NeveshtarUsers.txt', 'r')
        data=datas.readlines()
        print(data)
        n=self.user.text()
        print(n,'\n')
        print(data[1])
        if (data[1])==(n,'\n'):
            print('yeeeeesssss!')

I checked that data[1] is exactly equal self.user.text(), but when I code

n=self.user.text()

the output has an space after text, but data[1] don't have an space. so I can't continue my project. Please help me, if you can.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
F. Basiri
  • 1
  • 2

1 Answers1

0

I think its a trailing \n char. Try

n=self.user.text()
n.rstrip("\n")

To remove the newline

horse
  • 479
  • 7
  • 25