语法上,Python注释只有单行注释 # 注释内容
,习惯上Python使用三引号作为多行注释,但三引号本质上是字符串,可以单独作为函数体
def xxx1():
"""多行注释"""
def xxx2():
# 单行注释
# IndentationError: expected an indented block after function definition on line 1
Pycharm设置函数注释风格
# Python设置函数注释
# Preferences/Settings >> Tools >> Python Integrated Tools >> Doctrings
Epytext
"""
Epytext
@param x:
@param y:
@return:
"""
reStructuredText
"""
reStructuredText
:param x:
:param y:
:return:
"""
Numpy
"""
Numpy
Parameters
----------
x
y
Returns
-------
"""
"""
Google
Args:
x:
y:
Returns:
"""