【问题标题】:How to display images in webpage through a list of urls of images in Python/Django [closed]如何通过 Python/Django 中的图像 url 列表在网页中显示图像 [关闭]
【发布时间】:2015-10-02 19:15:18
【问题描述】:

我将图像的 URL 存储在 python 的列表中。
我应该如何使用 Django 在我的网页上显示这些图像。

【问题讨论】:

    标签: python django image-rendering


    【解决方案1】:

    尝试:

    # HTML file
    # If your list is 'urls'
    {% for url in urls %}
        <img src="{{ url }}" />
    {% endfor %}
    

    编辑

    从您的评论中,我得到了您的 Urls 列表,您应该像这样保存您的列表:

    ['toi.cricbuzz.com/scripts/images/toi-logo.gif', 'toi.cricbuzz.com/scripts/images/cb-logo.png', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/oct/2/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/oct/1/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/sep/27/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/sep/17/…']
    

    您可以在模板中测试上面的列表,它应该显示图像。

    【讨论】:

    猜你喜欢
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-24
    • 2019-07-05
    相关资源
    最近更新 更多