是否可以在Python中将图片嵌入到文档字符串中? [英] Is it possible embed pictures into docstring in Python?

查看:62
本文介绍了是否可以在Python中将图片嵌入到文档字符串中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Python中将图片嵌入到文档字符串中?

Is it possible embed pictures into docstring in Python?

我在某处看到 docpicture 关键字,但是找不到文档.是不是已经被刺死了?

I saw docpicture keyword somewhere, but can't find doc on it. Is it stabdartized or not?

图片应该放在哪里?

更新

我尝试了Sphinx表示法,但是我的PyCharm显示了

I tried Sphinx notation, but my PyCharm shows

即它看到这里应该是图像,但看不到图像文件.

i.e. it sees that it should be an image here, but doesn't see image file.

如果使用Sphinx,我会放在哪里?

Where I would put if used Sphinx?

推荐答案

这取决于您使用哪种工具来处理文档字符串.查看工具的文档以了解如何嵌入图像.

That depends on what tool you use for processing your docstring. Check your tool's documentation to find out how to embed images.

例如,如果您使用的是Sphinx,则可以使用 image 指令,如此说明中所述StackOverflow答案:

For example, if you are using Sphinx, you can use the image directive, as described in this StackOverflow answer:

.. image:: example.png

关于图片的位置,文档状态:

Regarding the location of the image, the documentation states:

在Sphinx中使用时,给定的文件名必须相对于源文件,或者是绝对的,这意味着它们相对于顶级源目录.例如,文件sketch/spam.rst可以将图像images/spam.png称为../images/spam.png或/images/spam.png.

When used within Sphinx, the file name given [...] must either be relative to the source file, or absolute which means that they are relative to the top source directory. For example, the file sketch/spam.rst could refer to the image images/spam.png as ../images/spam.png or /images/spam.png.

这篇关于是否可以在Python中将图片嵌入到文档字符串中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆