So I have been trying to figure out what I am doing wrong here with my if statement, It is apparently that I have two similar words which is filtered and unfiltered. What I am trying to do is that if a string is filtered, it should grab the values from filtered and vice versa with unfiltered.
I started to use Redis to have a sort of SQL however:
#getRedis.decode("utf-8").lower() --> is a list of ['filteredkeywords', 'unfilteredkeywords']
getInfo = filtered
redis = Redis()
if any(x in getInfo.lower() for x in ['filtered', 'unfiltered']):
redisURL = redis.redis.keys('*test')
else:
redisURL = redis.redis.keys('*Orange')
for getRedis in redisURL:
if any(x in getInfo.lower() for x in getRedis.decode("utf-8").lower()):
try:
print('show - {}'.format(getInfo.lower()))
print('show - {}'.format(getRedis.decode("utf-8").lower()))
informationValues = json.loads(redis.redis.get(getRedis))
except: # noqa
informationValues = []
outprint:
show - filtered
show - unfilteredkeywords
The first if statement of if any(x in getSite.lower() for x in ['filtered', 'unfiltered']):
seems to give the correct value of filtered/unfiltered however when we come to the second value which is:
if any(x in getSite.lower() for x in getRedis.decode("utf-8").lower()):
here is what goes wrong. It seems to always locate the value unfiltered even if the getInfo is filtered.
so my question is that how can I possible make a if statement that if getInfo = filtered
that means it should grab the value filtered and not the unfiltered one?
Aucun commentaire:
Enregistrer un commentaire