单行备注:
# 井号之后的代码都不会被执行
a=1 # 这里是单行备注,不会被执行
多行备注
"""
这里面无论加什么都不会执行
随便加
rm -fr /*
I love you all!
I hate you all!
"""
#
a= 1
同时备注多行:
选择多行然后,普通键盘:control+/;Mac键盘: Command+/

函数与函数包的Doc文件
def sparsity_ratio(x: np.array) -> float:
"""Return a float
Percentage of values in array that are zero or NaN
"""
以上文字将成为.doc的一部分
# -*- coding: utf-8 -*-
"""A module-level docstring
Notice the comment above the docstring specifying the encoding.
Docstrings do appear in the bytecode, so you can access this through
the ``__doc__`` attribute. This is also what you'll see if you call
help() on a module or any other Python object.
"""
参考
https://realpython.com/python-comments-guide/
https://www.python.org/dev/peps/pep-0257/#one-line-docstrings
网友评论