如何为 VS Code Intellisense 将使用的 Python 代码添加换行符

问题描述 投票:0回答:1

C# 也有类似的问题,但这个问题专门关于 Python Intellisense。

这段文字:

"""Create a Zendesk ticket with the given information.
    * The `description` is ???
    * The `body` is ???
    * Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

将产生:

但是有没有办法在没有

*
的情况下做到这一点?是否有一种不太明显的方法可以在文档字符串中添加换行符,将其转换为智能感知,而不会成为像这样的连续文本行?

"""Create a Zendesk ticket with the given information.
    The `description` is ???
    The `body` is ???
    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

将产生如下所示的智能感知:

python visual-studio-code intellisense
1个回答
4
投票

方法一

在句子末尾使用

\n
换行符

    """Create a Zendesk ticket with the given information. \n
    The `description` is ??? \n
    The `body` is ??? \n
    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

方法二

在句首添加空格

    """Create a Zendesk ticket with the given information.
      The `description` is ???
        The `body` is ???
      Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

方法三

每两行之间添加一个空行(可与方法二配合使用

    """Create a Zendesk ticket with the given information.
     The `description` is ???
    The `body` is ???

    Assigned_id values can be found in the settings/base.py file, use this very sparinglingly because
    people take vacations.  If in doubt, leave it out."""

© www.soinside.com 2019 - 2024. All rights reserved.