vendredi 29 juillet 2016

Python2.7 Read a file and use it for if in

So what I'm trying to do is use the below code to read a .txt file, and then use that in a if in statement. window is event.WindowName from pyHook.

try:
    with open("log.txt") as f:
        data = f.read().split()
except:
    print "Failed.1"
try:
    if data in window:
        #do stuff

It prints the data as ['foo', 'bar']... Any ideas?

Aucun commentaire:

Enregistrer un commentaire