In my code, I am trying to check a specific line of a config file by using linecache to read the line and an if statement to see if it is True, but for some reason it refuses to work.
I simplified the code in order to test it.
import linecache
d = linecache.getline('logconfig.dat', 2)
print(d)
if d == True:
doeslock = True
else:
doeslock = False
print(doeslock)
No matter what I try, print(d) will print True, and print(doeslock) will print False. I even tried using letters and strings instead of bools. Still didnt work. What am I missing here?
Thanks in advance guys
EDIT:
When I used strings to do the comparison, I replaced the True in the file with a y and modified the if statement to see if the d variable is 'y'
Aucun commentaire:
Enregistrer un commentaire