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

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -