将图像插入 IPython 笔记本降价 [英] Inserting image into IPython notebook markdown
问题描述
我开始严重依赖 IPython 笔记本应用程序来开发和记录算法.太棒了;但有些事情似乎应该是可能的,但我不知道该怎么做:
I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:
我想在我的(本地)IPython 笔记本降价中插入一个本地图像,以帮助记录算法.我知道的足以将诸如 <img src="image.png">
之类的内容添加到降价中,但就我所知,这大约是.我假设我可以将图像放在 127.0.0.1:8888 表示的目录(或某个子目录)中以便能够访问它,但我无法弄清楚该目录在哪里.(我在 mac 上工作.)那么,是否有可能在没有太多麻烦的情况下做我想做的事情?
I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like <img src="image.png">
to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?
推荐答案
notebook 目录中的文件在files/"网址下可用.因此,如果它在基本路径中,它将是 <img src="files/image.png">
,并且还可以使用 subdirs 等:<img src="files/subdir/image.png">
等
Files inside the notebook dir are available under a "files/" url. So if it's in the base path, it would be <img src="files/image.png">
, and subdirs etc. are also available: <img src="files/subdir/image.png">
, etc.
更新:从 IPython 2.0 开始,不再需要 files/
前缀(参见 发行说明).所以现在解决方案 <img src="image.png">
只是按预期工作.
Update: starting with IPython 2.0, the files/
prefix is no longer needed (cf. release notes). So now the solution <img src="image.png">
simply works as expected.
这篇关于将图像插入 IPython 笔记本降价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!