发布时间:2019-09-26 07:23:24编辑:auto阅读(2556)
环境:
python 3.7.4
redis集群 单集群(无slave)
很多文章都说redis密码,今天验证的了很多次失败,查了相关资料有才知道连接方式,一下为代码,修改123456为自己代码就可以使用了
from rediscluster import StrictRedisCluster
list = [
'02200000001',
'02200000002',
'02200000003',
'02200000004',
'02200000005',
'02200000006',
'02200000007',
'02200000008',
'02200000009',
'02200000010'
]
def redis_cluster():
redis_nodes = [
{'host':'192.168.0.56','port':7001},
{'host':'192.168.0.56','port':7002},
{'host':'192.168.0.56','port':7003},
]
# print(redis_nodes[1])
try:
redisconn = StrictRedisCluster(startup_nodes=redis_nodes,password='123456')
print(redisconn)
# redisconn.set('yyy','tttt')
# A=redisconn.set('yyy')
# print(A)
except:
print('error')
for i in range(0,len(list)):
redisconn.set('user_phone_'+list[i],'111111')
print(redisconn.get('user_phone_'+list[i]))
redis_cluster()
上一篇: python3 函数迭代器
下一篇: 4. python3 表达式if ...
51923
51696
42013
38852
33341
30313
28950
23964
23881
22249
352°
2582°
3253°
2706°
2689°
3423°
2651°
3484°
5736°
5529°