已有三张图片,写一个在JupyterLab上同时显示这三张图片的代码
时间: 2024-02-21 16:56:34 浏览: 85
您可以使用IPython.display模块中的HTML和Markdown类来实现在同一个窗口中显示三张图片的效果。以下是一个示例代码:
```python
from IPython.display import HTML, Markdown
title1 = '标题1'
image1_url = '图片1的URL'
title2 = '标题2'
image2_url = '图片2的URL'
title3 = '标题3'
image3_url = '图片3的URL'
html = f"""
<div>
<div style="display:flex;justify-content:center">
<div style="text-align:center;margin-right:20px">
<h2>{title1}</h2>
<img src="{image1_url}" alt="{title1}" style="max-width:100%;height:auto">
</div>
<div style="text-align:center;margin-right:20px">
<h2>{title2}</h2>
<img src="{image2_url}" alt="{title2}" style="max-width:100%;height:auto">
</div>
<div style="text-align:center">
<h2>{title3}</h2>
<img src="{image3_url}" alt="{title3}" style="max-width:100%;height:auto">
</div>
</div>
</div>
"""
display(HTML(html))
```
这段代码使用了HTML和CSS来实现标题和图片的对齐,并使用了max-width和height:auto来确保图片大小适应其容器。您只需要将图片的URL和标题替换为您自己的图片和标题即可。
阅读全文
相关推荐

















