简体   繁体   English

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

[英]Is it possible embed pictures into docstring in Python?

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

I saw docpicture keyword somewhere, but can't find doc on it. 我在某个地方看到了docpicture关键字,但是找不到它的文档。 Is it stabdartized or not? 它是否被刺破?

Where does picture should located? 图片应放在哪里?

UPDATE 更新

I tried Sphinx notation, but my PyCharm shows 我尝试了Sphinx表示法,但我的PyCharm显示

在此处输入图片说明

ie it sees that it should be an image here, but doesn't see image file. 即,它看到这里应该是图像,但是没有看到图像文件。

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. 查看工具的文档,以了解如何嵌入图像。

For example, if you are using Sphinx, you can use the image directive, as described in this StackOverflow answer : 例如,如果您使用的是Sphinx,则可以使用image指令, 如此StackOverflow答案中所述

.. image:: example.png

Regarding the location of the image, the documentation states: 关于图像的位置, 文档指出:

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. 在Sphinx中使用时,给定的文件名必须相对于源文件,或者是绝对的,这意味着它们相对于顶级源目录。 For example, the file sketch/spam.rst could refer to the image images/spam.png as ../images/spam.png or /images/spam.png. 例如,文件sketch / spam.rst可以将图像images / spam.png称为../images/spam.png或/images/spam.png。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM