logo
Loading...

D17 若不用...stream=True...會有什麼問題..?? - Cupoy

from shutil import move #.......其他部份和老師範例一樣.........

D17 若不用...stream=True...會有什麼問題..??

2023/01/18 下午 08:50
Python網路爬蟲實戰研習馬拉松 (2022新版)
強哥
觀看數:7
回答數:1
收藏數:0

```python from shutil import move #.......其他部份和老師範例一樣.......... with open(filename,'wb') as f: f.write(imgfile.content) img = Image.open(filename).format.lower() move(filename,filename+"."+img) ```

回答列表

  • 2023/02/23 下午 01:53
    王健安
    贊同數:0
    不贊同數:0
    留言數:0

    強哥 您好, 根據我在網路上查詢之各方文章, 若設定 stream = False,表示檔案會即可開始被下載, 此時硬碟受到下載的檔案而受到壓縮, 這也是 requests.get() 函數的預設值, 如設定為 stream = True,則會呈現一個可被遞迴物件, 只有當呼叫該物件並允許下載時才可以下載, 這可以避免下載的東西過多而造成硬碟不足,以及下載到無用的東西。 Reference: https://titangene.github.io/article/python-crawler-note.html https://blog.csdn.net/a12355556/article/details/113785207 https://www.aiuai.cn/aifarm1827.html