Python 中是否可以将图片嵌入到文档字符串中?
Is it possible embed pictures into docstring in Python?
是否可以在 Python 中将图片嵌入到文档字符串中?
我在某处看到了 docpicture
关键字,但找不到关于它的文档。有没有刺杀?
图片应该放在哪里?
更新
我尝试了 Sphinx 表示法,但我的 PyCharm 显示
即它在这里看到它应该是一个图像,但没有看到图像文件。
如果使用 Sphinx,我会放在哪里?
这取决于您使用什么工具来处理文档字符串。查看工具的文档以了解如何嵌入图像。
例如,如果您使用的是 Sphinx,则可以使用 image
指令,如 this Whosebug answer:
中所述
.. image:: example.png
关于图像的位置,documentation 指出:
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 中将图片嵌入到文档字符串中?
我在某处看到了 docpicture
关键字,但找不到关于它的文档。有没有刺杀?
图片应该放在哪里?
更新
我尝试了 Sphinx 表示法,但我的 PyCharm 显示
即它在这里看到它应该是一个图像,但没有看到图像文件。
如果使用 Sphinx,我会放在哪里?
这取决于您使用什么工具来处理文档字符串。查看工具的文档以了解如何嵌入图像。
例如,如果您使用的是 Sphinx,则可以使用 image
指令,如 this Whosebug answer:
.. image:: example.png
关于图像的位置,documentation 指出:
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.