亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將 gif 圖像添加到 Jupyter Notebook

如何將 gif 圖像添加到 Jupyter Notebook

蝴蝶不菲 2022-05-26 14:12:15
我正在嘗試使用網站提供的 iframe 和 JS 腳本將可視化鏈接到 Jupyter 筆記本:https ://public.flourish.studio/visualisation/1631776/但在筆記本中出現無效語法錯誤。我已經嘗試如下,關于問題的任何想法?from IPython.display import display, HTMLjs = "<div class="flourish-embed flourish-bar-chart-race" data-src="visualisation/1631776"> <script src="https://public.flourish.studio/resources/embed.js"></script></div>"display(HTML(js))錯誤:File "<ipython-input-4-5d8ce592337a>", line 2js = "<div class="flourish-embed flourish-bar-chart-race" data-src="visualisation/1631776"><script src="https://public.flourish.studio/resources/embed.js"></script></div>"                         ^SyntaxError: invalid syntax注意:我也嘗試從 git repo 加載相同的 gif,如下所示,但出現超時錯誤:import matplotlib.pyplot as pltimport matplotlib.image as mpimgimg = mpimg.imread("https://github.com/rsyed1/kaggle/blob/master/Cases2020.gif?raw=true")plt.imshow(img)錯誤:gaierror                                  Traceback (most recent call last)/opt/conda/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args)1317                 h.request(req.get_method(), req.selector, req.data, headers,-> 1318                           encode_chunked=req.has_header('Transfer-encoding'))1319             except OSError as err: # timeout error
查看完整描述

1 回答

?
斯蒂芬大帝

TA貢獻1827條經驗 獲得超8個贊

為 iframe 嘗試以下操作:


import IPython

url = "https://public.flourish.studio/visualisation/1631776/"

iframe = '<iframe src=' + url + ' width=700 height=350></iframe>'

IPython.display.HTML(iframe)

忽略警告,因為它建議的版本目前不起作用。


使用代碼顯示 gif:


from IPython.display import Image

Image("https://raw.githubusercontent.com/rsyed1/kaggle/master/Cases2020.gif")

要將您的 gif 圖像放在markdown 單元格中,請使用:


![display image](https://raw.githubusercontent.com/rsyed1/kaggle/master/Cases2020.gif)


查看完整回答
反對 回復 2022-05-26
  • 1 回答
  • 0 關注
  • 307 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號