Какие члены отображаются в документах модуля python? [Дубликат]

Попробуйте

$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
echo $data["operacion"];

Из вашего json и вашего кода, похоже, что вы правильно произвели операцию слова на вашем конце, но это не в json.

EDIT

Возможно, также стоит попробовать эхо-строку json из ввода php: //.

echo file_get_contents('php://input');
52
задан Brad Gilbert 16 September 2008 в 18:06
поделиться

5 ответов

Для пакетов вы можете документировать его в __init__.py. Для модулей вы можете добавить docstring просто в файл модуля.

Вся информация здесь: http://www.python.org/dev/peps/pep-0257/

40
ответ дан Grégoire Cachet 20 August 2018 в 15:25
поделиться

Добавьте docstring в качестве первого оператора в модуле .

Поскольку мне нравится видеть пример:

"""
Your module's verbose yet thorough docstring.
"""

import foo

# ...
34
ответ дан Brad Koch 20 August 2018 в 15:25
поделиться

Вы делаете это точно так же. Поместите строку в качестве первого оператора в модуле.

7
ответ дан Chris Upchurch 20 August 2018 в 15:25
поделиться
  • 1
    Это то, что затмение делает автоматически при создании нового модуля. – Rivka 29 August 2011 в 14:41

Это легко, вы просто добавили docstring в верхней части модуля.

4
ответ дан David Locke 20 August 2018 в 15:25
поделиться

Вот пример Пример Docstrings в стиле Python в стиле Google о том, как модуль может быть документирован. В основном есть информация о модуле, как его выполнять и информация о переменных уровня модуля и список элементов ToDo.

"""Example Google style docstrings.

This module demonstrates documentation as specified by the `Google
Python Style Guide`_. Docstrings may extend over multiple lines.
Sections are created with a section header and a colon followed by a
block of indented text.

Example:
    Examples can be given using either the ``Example`` or ``Examples``
    sections. Sections support any reStructuredText formatting, including
    literal blocks::

        $ python example_google.py

Section breaks are created by resuming unindented text. Section breaks
are also implicitly created anytime a new section starts.

Attributes:
    module_level_variable1 (int): Module level variables may be documented in
        either the ``Attributes`` section of the module docstring, or in an
        inline docstring immediately following the variable.

        Either form is acceptable, but the two should not be mixed. Choose
        one convention to document module level variables and be consistent
        with it.

Todo:
    * For module TODOs
    * You have to also use ``sphinx.ext.todo`` extension

.. _Google Python Style Guide:   
http://google.github.io/styleguide/pyguide.html

"""

module_level_variable1 = 12345

def my_function():   
    pass 
... 
...
10
ответ дан Vlad Bezden 20 August 2018 в 15:25
поделиться
Другие вопросы по тегам:

Похожие вопросы: