Handling Encoding Issues Using Redis with Python
Pythond์์ Redis ์ฌ์ฉ์ encoding issue ํด๊ฒฐ ๋ฐฉ๋ฒ
Problem
:Python ์์ Redis์ ๋ฌธ์์ด์ publish ํ๋ฉด binary๋ฅผ return ํ๋ ๋ฌธ์ ๋ฐ์
Solution
: Redis Python interface ๊ฐ Redis connection class์ ๋ํด ์ ๊ณตํ๋ decode_responses option์ ํ์ฉํ์ฌ ํด๊ฒฐํ ์ ์๋ค
ex)

์์ ์์์ ๊ฐ์ด decode_responses option์ True๋ก ์ค์ ํ๋ฉด, client๋ ์ค์ ํ encoding option์ ์ด์ฉํ์ฌ decodeํ ๊ฒฐ๊ณผ๊ฐ์ return ํด์ค๋ค
์์์์๋ ๋ช ์์ ์ผ๋ก **charset="utf-8"**๋ก ํํํ์ผ๋ encoding default ๊ฐ์ด utf-8์ด๋ฏ๋ก ์๋ตํด๋ ๋๋ค
References
Last updated
Was this helpful?