python - Test if user has entered a word equal to a word in a text file -


Assume that I have a file in it:
  passcode  

/ Pre>

Now, whatever I want to do, there is some code with user input, which should check what the user has entered in the file that is in the same. Is there any way I can do that? As a file I already have such a code:

  with file ('test.txt') f: s.strip ('\ n') s = f.read ( ) Inp = raw_input () if inp == s: print "provide access" other: print "login denied!"    

I took your code and finally added the following line:

 print repr (inp), repr (s)   

I got the output

  'passcode' passcode \ n ' < / Pre> 

Obviously raw_input () Finally the new line is included, close the tab and it should work.

Comments

Popular posts from this blog

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -