pycharm python函数描述中如何断行?

omvjsjqw  于 2022-12-18  发布在  PyCharm
关注(0)|答案(1)|浏览(150)

我试着找到在Python函数描述中如何换行的解决方案,但是没有一个对我有效。我有这样一个函数:

但当我悬停在该函数上时,显示的描述显示了连续的字符链,没有中断,如下所示:

如何在函数desc中设置隔断线?
编辑:由于请求,我张贴的代码(当粘贴的代码缩进已打破):

from pandas import PandasDataFrame
def calculate_input_types(price_df: PandasDataFrame, calculate_all: bool = True, *, input_type: dict) -> PandasDataFrame:
    """
    :param price_df: price_df: Dataframe containing Open, Close, High, Low, Volume price data.
    :param calculate_all: Boolean value True or False, if True function calculates all possible input types.
        HL2, HLC3, OHLC4, HLCC4, if False function calculates only chosen input types, must pass a dictionary.
    :param input_type: Optional argument, mandatory if calculate_all is set to False. A dictionary should posses input
        types as keys and one-hot encoded value of 1 if the input type is to be calculated
        or 0 if the input type shouldn't be calculated.
        Example of input_type:
        input_type = {
                HL2 : 1,
                HLC3 : 1,
                OHLC4 : 0,
                HLCC4 : 1
        }
        This type of input calculates only HL2, HLC3 and HLCC4 since those are set to 1 and OHLC4 is set to 0.

    :return: Dataframe with calculated input types.
    """
    return 'apple'
e7arh2l6

e7arh2l61#

我设法在一定程度上解决了这个问题:

from pandas import PandasDataFrame

def calculate_input_types(price_df: PandasDataFrame, calculate_all: bool = True, *, input_type: dict) -> PandasDataFrame:
    """
    Example of input_type:\n
    input_type = {
        HL2 : 1,\n
        HLC3 : 1,\n
        OHLC4 : 0,\n
        HLCC4 : 1\n
    }\n
    :param price_df: price_df: Dataframe containing Open, Close, High, Low, Volume price data.
    :param calculate_all: Boolean value True or False, if True function calculates all possible input types.
        HL2, HLC3, OHLC4, HLCC4, if False function calculates only chosen input types, must pass a dictionary.
    :param input_type: Optional argument, mandatory if calculate_all is set to False. A dictionary should posses input
        types as keys and one-hot encoded value of 1 if the input type is to be calculated
        or 0 if the input type shouldn't be calculated.
    :return: Dataframe with calculated input types.
        This type of input calculates only HL2, HLC3 and HLCC4 since those are set to 1 and OHLC4 is set to 0.
    """
    return 'apple'

相关问题