代码之家  ›  专栏  ›  技术社区  ›  david

Jupyter显示几个图像

  •  0
  • david  · 技术社区  · 4 年前

    我有一个图像url列表,想用Jupyter显示它们。 由于一个图像可以,因此在列表上循环时不显示图像:

    liste_images = ['http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=447344&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=450248&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=447345&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=450252&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=469854&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=466953&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=469851&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=461108&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=461109&type=card',
     'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=461107&type=card']
    

    我尝试的方式是:

    import requests
    from IPython.display import Image
    for url_image_carte in liste_images:
        Image(requests.get(url_image_carte).content)
    

    enter image description here

    1 回复  |  直到 4 年前
        1
  •  1
  •   Anwarvic    4 年前

    只是使用 IPython.display.display 就像这样:

    import requests
    from IPython.display import Image, display
    for url_image_carte in liste_images:
        display( Image(requests.get(url_image_carte).content) ) #added display