From 28df8ea6a647d48481fedbb6566f4e0ce2f638c0 Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 24 Sep 2019 19:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=86=99=E5=85=A5redis?= =?UTF-8?q?=EF=BC=8C=E5=8F=A6=E4=B8=80=E4=B8=AA=E8=84=9A=E6=9C=AC=E5=B0=86?= =?UTF-8?q?REDIS=E6=95=B0=E6=8D=AE=E5=86=99=E5=85=A5=E6=95=B0=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dump2shushu.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dump2shushu.py b/dump2shushu.py index 89b1936..5d97d0c 100644 --- a/dump2shushu.py +++ b/dump2shushu.py @@ -51,7 +51,11 @@ def get_from_redis(): all = [] for i in range(1, 1000): try: - all.append(json.loads(my_redis.brpop(redis_key))) + one_line = my_redis.lpop(redis_key) + if one_line: + all.append(json.dumps(one_line)) + else: + continue except Exception: log.error(f"get data failed!", exc_info=True) for one in all: