繁体   English   中英

Python 文档字符串注释,大于和小于符号未显示

[英]Python Docstring Comments, Greater Than and Less Than Symbols Not Showing

我正在使用文档字符串注释 Python 代码。 注意,这只是一个例子,

def credit_bonus(self, num_purchases: int, total_spend: float)->int:
    '''
    Calculates eligible and additional credit bonus for a customer, compared to previous
    yearly spends, and number of previous purchases.

    Additional credit ranking of 2, if current number of purchases > previous purchaces, 
    and current spend >= 95% previous spend.

    Return: customer's credit ranking
    '''

    ....

    return credit_rank

当显示此函数的注释时,在 VSCode 中,将鼠标悬停在调用它的另一个模块中的此函数上时,不显示大于号。 我尝试了各种转义字符, > ,到目前为止没有任何效果。

是否可以在 Python 文档字符串中显示 < 和 >?

另外,我知道这不是表演障碍,也不是命令式,只是一个小小的方便,最终会打字,大于,而不是。

谢谢和问候,新泽西州

为函数/方法 DocStrings 工作,而不是为类工作。 自发布以来,我仍在 DocStrings 中键入 < 和 >,并且我注意到它(现在?)在哪里起作用,哪里不起作用。 首先是一些规格;

  • Windows 10 专业版 x64 20H2
  • Visual Studio Code x64 1.52.1
  • 适用于 Visual Studio Code 的 Microsoft Python 扩展 2020.12.424452561

我确实为函数或方法工作,

def __new_connection(self)->sqlite3.Connection:
    '''
     __new_connection(self)`->`sqlite3.Connection:\n
     create a new connection using a connection string, time out, and isolation level settings.\n

     return:
         sqlite3.Connection.
    '''
    return sqlite3.connect(database=self.__con_str, timeout=self.__timeout, isolation_level=None, uri=True)

>或在本例中->周围键入尖引号或反引号,将显示 < 和 > 符号,当 DocString 显示为方法描述时。

对于类文档字符串,它不起作用。

class Broker:
    '''
     class wrapper for sqlite3 database objects and operations.\n
     transaction type: auto-commit.\n
     database type: file system database. not in-memory (:memory:)
     isolation level is set to None, i.e. auto-commit, cache is private.

     methods:\n
         __new_connection(self)->sqlite3.Connection
         creates a new sqlite3 connection object

         __cursor_execute(self, conn: sqlite3.Connection, sqlCmd: str, params: tuple=())->sqlite3.Cursor
        creates a cursor object, execute a parameterised sql statement
    '''

无论在 < 或 > 周围放置什么符号或标记,都不起作用。

如果我找到 DocStrings 类的解决方法,我将再次发布,假设它不起作用(仍然),如果我这样做了。

谢谢和问候,新泽西州

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM