python - Python 在文档字符串中格式化 JSON
问题描述
您好,我正在尝试在 Python 中创建这样的文档字符串:
def hello_world_request(self, json):
"""
foo
Example JSON:
{
"helloWorld": [
{
"firstWord": "Hello",
"lastWord": "World",
"comment": "foo"
}
]
}
:param json: json object
"""
查看下图,您可以看到文档。是否可以让文档字符串中的每一行在文档中也显示为单独的行?所以它看起来像函数的文档字符串。
解决方案
弄清楚了
"""
foo
.. code-block:: json
{
"helloWorld": [
{
"firstWord": "Hello",
"lastWord": "World",
"comment": "foo"
}
]
}
:param json: json object
"""
推荐阅读
- local-storage - 如何在 Blazor 代码隐藏文件中使用 Blazored.LocalStorage
- php - Laravel/Installer + Composer 的问题
- flutter - 如何更改 ListView.itemBuilder 中特定行中点击按钮的颜色
- python - I dont understand what I typed wrong on def function but it is all correct on Python?
- javascript - React/next.js - 为什么组件不能由我定义的序列生成?
- php - 为什么我无法检索数据 - Codeigniter?
- python - 在 Pycharm for Python 上导入 json
- java - 在 Android Studio 中单击按钮时呈现新视图
- javascript - 在 fullcalendar 中使用资源 - 测试
- postgresql - 在postgres中获得2个日期的日差