From 62541f5103023eeb2b25dcedbfc46a123c7de0cc Mon Sep 17 00:00:00 2001 From: pnhekgfuf <1913997697@qq.com> Date: Sat, 29 Apr 2023 12:18:36 +0800 Subject: [PATCH] ADD file via upload --- Scrapy-Redis-Zhihu/scrapy_redis/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Scrapy-Redis-Zhihu/scrapy_redis/utils.py diff --git a/Scrapy-Redis-Zhihu/scrapy_redis/utils.py b/Scrapy-Redis-Zhihu/scrapy_redis/utils.py new file mode 100644 index 0000000..b1a4681 --- /dev/null +++ b/Scrapy-Redis-Zhihu/scrapy_redis/utils.py @@ -0,0 +1,8 @@ +import six + + +def bytes_to_str(s, encoding='utf-8'): + """Returns a str if a bytes object is given.""" + if six.PY3 and isinstance(s, bytes): + return s.decode(encoding) + return s