import redis import json tag_key = "service_home_icon_city_sort" tag_value = dict() T1 = [328,592,409] T2 = [604,352,675,662,343,542,425,359,744,493] T3 = [430,538,603,376,623,670,550,660,400,674,606,395,382,543,572,468,638,412] tag_value["t1_city"] = json.dumps(T1) tag_value["t2_city"] = json.dumps(T2) tag_value["t3_city"] = json.dumps(T3) boniaosuan = [1055] chuzhoushoulian = [79, 922, 2033] zhushemeirong = [2059, 2060, 2941] kouqiangchike = [53, 154, 155, 157, 158] yanbu = [1, 15] bibu = [2, 21] mianbulunkuo = [3, 813, 1136] zhifangtianchong = [120, 153, 198, 201, 241, 244, 933, 1024, 1233] xizhishoushen = [38, 221, 226, 228, 236, 836, 906, 909, 982, 986, 2934, 5868] kangshuailao = [61, 822, 872, 873, 931, 2352, 2866, 5072] xiongbu = [66, 212] yixuemeifu = [41, 47, 78, 1387, 1992, 2938, 2942, 6933, 6941] simi = [955] tuomao = [865, 2663, 2947] zhifa = [37, 76, 251, 983] chunbu = [12, 52, 148, 149, 150, 151, 152, 153, 864, 904, 907, 908, 910] xiaba = [46, 123, 125, 126, 127, 128, 784, 967] shibaixiufu = [64, 65, 70, 81, 103, 210, 869, 878, 964, 965, 967, 968, 969, 2429] banyongjiuwenjiu = [2054, 6944] rule = {"t1_"+str(sorted(boniaosuan)):1, "t2_"+str(sorted(boniaosuan)):1, "t3_"+str(sorted(boniaosuan)):2, "t4_"+str(sorted(boniaosuan)):3, "t1_"+str(sorted(chuzhoushoulian)):1, "t2_"+str(sorted(chuzhoushoulian)):1, "t3_"+str(sorted(chuzhoushoulian)):2, "t4_"+str(sorted(chuzhoushoulian)):3, "t1_"+str(sorted(zhushemeirong)):1, "t2_"+str(sorted(zhushemeirong)):1, "t3_"+str(sorted(zhushemeirong)):2, "t4_"+str(sorted(zhushemeirong)):3, "t1_" + str(sorted(kouqiangchike)): 1, "t2_" + str(sorted(kouqiangchike)): 1, "t3_" + str(sorted(kouqiangchike)): 2, "t4_" + str(sorted(kouqiangchike)): 2, "t1_" + str(sorted(yanbu)): 1, "t2_" + str(sorted(yanbu)): 2, "t3_" + str(sorted(yanbu)): 2, "t4_" + str(sorted(yanbu)): 3, "t1_"+str(sorted(bibu)):1, "t2_"+str(sorted(bibu)):2, "t3_"+str(sorted(bibu)):2, "t4_"+str(sorted(bibu)):3, "t1_"+str(sorted(mianbulunkuo)):1, "t2_"+str(sorted(mianbulunkuo)):2, "t3_"+str(sorted(mianbulunkuo)):2, "t4_"+str(sorted(mianbulunkuo)):3, "t1_"+str(sorted(zhifangtianchong)):1, "t2_"+str(sorted(zhifangtianchong)):2, "t3_"+str(sorted(zhifangtianchong)):2, "t4_"+str(sorted(zhifangtianchong)):3, "t1_" + str(sorted(xizhishoushen)): 1, "t2_" + str(sorted(xizhishoushen)): 2, "t3_" + str(sorted(xizhishoushen)): 2, "t4_" + str(sorted(xizhishoushen)): 3, "t1_" + str(sorted(kangshuailao)): 1, "t2_" + str(sorted(kangshuailao)): 1, "t3_" + str(sorted(kangshuailao)): 2, "t4_" + str(sorted(kangshuailao)): 3, "t1_" + str(sorted(xiongbu)): 1, "t2_" + str(sorted(xiongbu)): 2, "t3_" + str(sorted(xiongbu)): 2, "t4_" + str(sorted(xiongbu)): 3, "t1_" + str(sorted(yixuemeifu)): 1, "t2_" + str(sorted(yixuemeifu)): 1, "t3_" + str(sorted(yixuemeifu)): 2, "t4_" + str(sorted(yixuemeifu)): 2, "t1_" + str(sorted(simi)): 1, "t2_" + str(sorted(simi)): 1, "t3_" + str(sorted(simi)): 2, "t4_" + str(sorted(simi)): 3, "t1_" + str(sorted(tuomao)): 1, "t2_" + str(sorted(tuomao)): 2, "t3_" + str(sorted(tuomao)): 2, "t4_" + str(sorted(tuomao)): 2, "t1_" + str(sorted(zhifa)): 1, "t2_" + str(sorted(zhifa)): 2, "t3_" + str(sorted(zhifa)): 2, "t4_" + str(sorted(zhifa)): 3, "t1_" + str(sorted(chunbu)): 1, "t2_" + str(sorted(chunbu)): 2, "t3_" + str(sorted(chunbu)): 2, "t4_" + str(sorted(chunbu)): 3, "t1_" + str(sorted(xiaba)): 1, "t2_" + str(sorted(xiaba)): 2, "t3_" + str(sorted(xiaba)): 2, "t4_" + str(sorted(xiaba)): 3, "t1_" + str(sorted(shibaixiufu)): 1, "t2_" + str(sorted(shibaixiufu)): 2, "t3_" + str(sorted(shibaixiufu)): 4, "t4_" + str(sorted(shibaixiufu)): 5, "t1_" + str(sorted(banyongjiuwenjiu)): 1, "t2_" + str(sorted(banyongjiuwenjiu)): 2, "t3_" + str(sorted(banyongjiuwenjiu)): 2, "t4_" + str(sorted(banyongjiuwenjiu)): 2 } tag_value["sort_rule"] = json.dumps(rule) r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379') r.hmset(tag_key,tag_value)