Traceback (most recent call last):
File "/home/shenjianlin/.local/lib/python3.4/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/home/shenjianlin/my_project/Espider/Espider/pipelines/searchwebsitepipeline.py", line 37, in process_item
iconUrl=self.get_max_size_url(item['iconUrl'])
File "/home/shenjianlin/my_project/Espider/Espider/pipelines/searchwebsitepipeline.py", line 18, in get_max_size_url
save_path = os.path.join("./image", hashlib.sha1(res.content))
File "/usr/lib64/python3.4/posixpath.py", line 79, in join
if b.startswith(sep):
AttributeError: '_hashlib.HASH' object has no attribute 'startswith'### 题目描述
类型不正确.
os.path.join
期待传入一个字符串类型的参数, 而你这里传入了一个_hashlib.HASH
类型的对象.我估计你是想获取
HASH
的 16 进制结果.可以用hexdigest
方法, 就像这样:或者返回 Bytes 类型, 然后再转码(不推荐):
参考:
python hashlib doc