python简单连接redis

 1 from redis import StrictRedis
 2 def demo():
 3     sr = StrictRedis(host='192.168.2.180')
 4     try:
 5         result = sr.set('name','itheima')
 6         print(result)
 7     except Exception as e:
 8         print(e)
 9 if __name__ == '__main__':
10     demo()
posted @ 2019-06-14 08:21  mia0812  阅读(168)  评论(0编辑  收藏  举报