S
S
Sadig Sadigov2019-03-06 18:42:14
Python
Sadig Sadigov, 2019-03-06 18:42:14

How to use redis?

Why is test1 not output here?

import redis 
  

# задаем параметры базы redis: находится на localhost, стандартный порт 6397, номер базы 1 (по дефолту создается сразу 16: от 0 до 15)
r = redis.StrictRedis(host='localhost', port=6646, db=1)

#присваиваем переменной test1 значение 5
r.set('test1',5)

#получаем из переменной test1 значение
test1 = r.get('test1')

print(test1)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-03-06
@sadigsadigov

You should first learn the language, and only then deal with the libraries
test1 = r.get('test1')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question