Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.06 KB

关于Python标准库.md

File metadata and controls

18 lines (13 loc) · 1.06 KB
待补

下载图片时gzip碰到一个bug:

  File "/Users/hipponensis/myprojects/crawlertool/douban_movies.py", line 136, in crawler_image
    image_data = g.read()
  File "/Users/hipponensis/.pyenv/versions/3.5.1/lib/python3.5/gzip.py", line 274, in read
    return self._buffer.read(size)
  File "/Users/hipponensis/.pyenv/versions/3.5.1/lib/python3.5/gzip.py", line 461, in read
    if not self._read_gzip_header():
  File "/Users/hipponensis/.pyenv/versions/3.5.1/lib/python3.5/gzip.py", line 409, in _read_gzip_header
    raise OSError('Not a gzipped file (%r)' % magic)

看了这个, 了解到原因是内置模块设计不合理。

又看了这个这个, 最后使用shutil.copyfileobj问题解决, 但数据未压缩比较耗流量, 等下次抽空优化。