logo
Loading...

D3_hw2不知道要怎麼同時讀取五張圖片 - Cupoy

不知道要怎麼同時讀取五張圖片,現在想法是將五個連結包在list裡面,但不知道要在哪邊放入list是r...

ml100-2,append,ml100-2-d03

D3_hw2不知道要怎麼同時讀取五張圖片

2019/04/30 上午 02:15
機器學習共學討論版
Python_韭菜
觀看數:20
回答數:3
收藏數:0
ml100-2
append
ml100-2-d03

不知道要怎麼同時讀取五張圖片,現在想法是將五個連結包在list裡面,但不知道要在哪邊放入list

是response = requests.get這裡?

Image.open(BytesIO(response.content))這裡?

還是轉成numpy array這裡?

然後要怎麼讀取list?直接放進去都error

回答列表

  • 2019/04/30 上午 02:40
    張維元 (WeiYuan)
    贊同數:2
    不贊同數:0
    留言數:0

    可以將讀出來的圖片 append 到列表當中最後形成「由多個圖片物件組成的 LIST」,像這樣:

    [<Img Object>, <Img Object>, ...]

  • 2019/04/30 上午 08:47
    Seanyu.TW
    贊同數:1
    不贊同數:0
    留言數:0

    要先建立一個空的 list, 之後再回圈內 append 即可

  • 2019/04/30 上午 08:49
    Seanyu.TW
    贊同數:1
    不贊同數:0
    留言數:0

    概念上的程式碼是這樣

    result = []
    for i in range(5):
      try:
        im = ... (open image and convert to array)
        result.append(im)
      except:
        ... cannot request image, skip it.