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()
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()