python에서 redis 연결하여 사용할 경우 "b" 문자가 출력됨 >>> r = redis.StrictRedis(host='localhost', port=6379, db=0) >>> r.set('test_redis', 'Hello Python') >>> r.get('test_redis')b'Hello Python' --> byte 문자열이란 뜻으로 해결을 위해서는 다음 unicode를 명시적으로 사용하여 수정함.>>> r = redis.StrictRedis(host="localhost", port=6379, charset="utf-8", decode_responses=True) >>> r.set('test_redis', 'Hello Python') >>> r.get('test_redis')
In [11]: class Vec: def __init__(self, labels, function): self.D=labels self.f=functionv=Vec(['A', 'B', 'C'], {'A':1})for d in v.D: if d in v.f: print(v.f[d])def zero_vec(D): return Vec(D, {d:0 for d in D})d={1,2,3,4,5,6,7,8}dp = zero_vec(d)print(dp) 1 In [34]: class Vec: def __init__(self, labels, function): self.D=labels self.f=functionv=Vec(['A', 'B', 'C'], {'A':1})def setitem(v, d, val) ..